santoish / SampleRepo

0 stars 0 forks source link

PHP #1

Open santoish opened 5 days ago

santoish commented 5 days ago

I Greeting Text <?php echo "Welcome to PHP Programming !!!!"."
"; echo "This", " string", " was", " made", " with multiple parameters."; echo ("Welcome to PHP Programming !!!!"."
"); print("Welcome to PHP"."
"); print "Hello World"; ?> OUTPUT: Welcome to PHP Programming !!!! This string was made with multiple parameters.Welcome to PHP Programming !!!! Welcome to PHP Hello World

II Palindrome:

Enter a Number:

<?php
if($_POST)
{
//get the value from form
$num = $_POST['num'];
//reversing the number
$reverse = strrev($num);

    //checking if the number and reverse is equal  
    if($num == $reverse){  
        echo "The number $num is Palindrome";     
    }else{  
        echo "The number $num is not a Palindrome";   
    }  

}
?>

III Armstrong Number

Enter the Number:

<?php
if($_POST)
{
//get the number entered
$number = $_POST['number'];
//store entered number in a variable
$a = $number;
$sum = 0;
//run loop till the quotient is 0
while( $a != 0 )
{
$rem = $a % 10; //find reminder
$sum = $sum + ( $rem $rem $rem ); //cube the reminder and add it to the sum variable till the loop ends
$a = $a / 10; //find quotient. if 0 then loop again
}
//if the entered number and $sum value matches then it is an armstrong number
if( $number == $sum )
{
echo "Yes $number an Armstrong Number";
}else
{
echo "$number is not an Armstrong Number";
}
}
?>

IV Function(Recursive)

<?php
function display($number) {
if($number<=5){
echo "$number
";
display($number+1);
}
}

display(1);
?>

V Login

Login

Username
Password

VI Session

LOGIN.PHP

<?php session_start();

if(isset($_SESSION['user'])) { header("Location:home.php"); } if(isset($_POST['login'])) { $username=$_POST['uname']; $password=$_POST['pass']; if($username=="christhu" && $password=="110605") { $_SESSION['user']=$username; echo''; } else{ echo'

invalid username and password

'; } } ?> <!DOCTYPE html>

LOGIN
LOGIN

USERNAME

PASSWORD

HOME.PHP

<!DOCTYPE html>

home '; echo'

login successfully

'; echo $_SESSION['user']; echo '

LOGOUT

'; ?>

LOGOUT.PHP

<?php session_start();

echo 'logout successfully'; session_destroy(); header("Location:login.php"); ?>

VII Log in with SQL

login.php

<!DOCTYPE html>

login page

USERNAME

PASSWORD



logincheck.php

<?php if(!isset($_POST['submit'])) { $username=$_POST['username']; $password=$_POST['password']; $con= new mysqli("localhost","root","","admin"); $sql="SELECT*from login WHERE username='$username' and password='$password'"; $result=mysqli_query($con,$sql); $resultcheck=mysqli_num_rows($result); if($resultcheck>0) { echo'

LOGIN SUCCESSFULLY

'; } else{ echo'

USERNAME AND PASSWORD INVAILD

'; } }

?>

osmankiv commented 3 days ago

ok thanks