Skip to main content

Posts

External Page Submission/Submission to another page

Tutorial Title:   External Page Submission/Submission to another page Course: PHP Instructor: Muhammad Samim 1. Submitting action from one page to another page 2. First make one page with name page1.php <!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8">     <title>Document</title> </head> <body>      <form action="page2.php" method="post"> //It will direct from page1.php to page2.php           <br><input type="text" placeholder="Email" name="anyNameForEmail">     <br><input type="password" placeholder="Password" name="anyNameForPassword">     <br><input type="submit" name="click">    </form>   </body> </html> 3. Second make another file with name page2.php <?php if(isset($_POST["click"])){     $anyNameO...
Recent posts

Validating The Form Values

Tutorial Title:  Validating The Form Values Course: PHP Instructor: Muhammad Samim 1. Understanding of Different Validation <?php if(isset($_POST["click"])){     $anyNameOfVariableForUserName = $_POST["anyNameForEmail"];     $anyNameOfVariableForPassword = $_POST["anyNameForPassword"];     $validEmail  = array("Muhammad","Samim","Akhtar","Akbar"); //Array of valid names     $minimum = 3;     $maximum = 15;     if (strlen($anyNameOfVariableForUserName) < $minimum) //strlen will check the length of the string     {         echo "Email Error: Minimum characters are 5";     }       elseif (strlen($anyNameOfVariableForUserName) > $maximum) //strlen will check the length of the string     {         echo "<br>Email Error: Maximum characters are 12";     }     else {     ...

Extracting Information from form

Tutorial Title:  Extracting Information from form Course: PHP Instructor: Muhammad Samim 1. <?php if(isset($_POST["anyName"])) { $anyNameOfVariableForEmail = $_POST["anyNameForEmail"]; //Now because of it email must be typed otherwise it will not work $anyNameOfVariableForPassword = $_POST["anyNameForPassord"];//Now because of it password must be typed otherwise it will not work echo $anyNameOfVariableForEmail; //It will display the email echo $anyNameOfVariableForPassword; //It will display the password } ?> <!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8">     <title>Document</title> </head> <body>      <form action="21form.php" method="post">        <input type="text" placeholder="Email" name="anyNameForEmail">        <input type="password" placeholder="...

Forms in PHP

Tutorial Title:  Forms in PHP Course: PHP Instructor: Muhammad Samim 1. $_POST is a global super variable 2. It picks up the data in post forms 3. Declaring form <form action=""></form> //Or in Bracket editor just type form and press tab button rest will be come automatically 4. Declaring input in form and some types of it <input type="text">           //for text box <input type="password"> //for password <input type="submit">    //for submit button 5. Declaring placeholder in input inside form <input type="text" placeholder="Email"> //Email will be displayed inside the textbox <input type="password" placeholder="Password"> //Password will be displayed inside password box 6. Complete coding to understand <?php        //It will not be executed unless we don't click or enter the submit button if(isset($_POST["anyName...

Builtin or Predefined Functions in PHP

Tutorial Title:  Builtin or Predefined Functions in PHP Course: PHP Instructor: Muhammad Samim 1.  Predefined Math Functions in PHP Math predefined functions make easier coding echo pow(2,7); //2 power of 7 will be displayed echo rand(1, 1000); //Random numbers between 1 and 1000 echo sqrt(100); //Square root of 100   echo ceil(5.6) // Round up of 5.6 echo floor(5.6) //Round down of 5.6 echo round(5.6) //Round of 5.6 For more  Click Here! 2. Predefined String Functions in PHP $variableName = "Muhammad Samim"; echo strlen($variableName); //Length of string inside $variableName echo strtoupper($variableName); //Converting to upper case of string inside $variableName echo strtolower($variableName); //Converting to lower case of string inside $variableName Fore more  Click Here! 3. Predefined Array Functions in PHP Predefined functions for arrays $arrayName = [345,56,6,78,45,3543,0]; echo max($arrayName); //Displays th...

Custom Function in PHP

Tutorial Title:  Custom Function in PHP Course: PHP Instructor: Muhammad Samim 1 . Defining Functions in PHP User defined function is a piece of program that can be used calling by its name. It saves a lot of time and makes easier to code. function anyName(){ echo "Powered by Muhammad Samim"; } //it will not be shown until we don't call anyName(); //Displays whatever function contains 2. Passing Parameters Functions in PHP function anyName($number1, $number2){ $sum = $number1 + $number2; echo $sum; } anyName(300,60.55); //These two numbers will be passed through variables $number1 and $number2 and will be added to be stored in variable $sum to be displayed. 3. Returning Values from Functions Using keyword return of PHP in function to make it more flexible.  function anyName($number1, $number2){ $sum = $number1 + $number2; return $sum; } $result = anyName(300,400); echo $result . "<br>"; //Here we can use the stored value ...

Control Structures in PHP

Tutorial Title:  Control Structures in PHP Course: PHP Instructor: Muhammad Samim 1. If, elseif and else statements in PHP These are the conditions which are applied to control the flow of program if(3<2) { echo "First condition";} elseif (3>10) {echo "Second condition;} else {echo "all conditions are false";} //"all conditions are false" will be displayed because because above both conditions are false 2. Comparison operators in PHP Equal == //e.g 3 == "3" This condition will be true, datatypes are change but values are same Identical ===   //To identify if both values are same and of same datatype e.g 3 === "3" This condition will be false because values are same but datatypes are change Less than < Greater than > Less than or Equal to <= Greater than or Equal to >= Less than or Greater than <> Not Equal  != Not Identical !== 3. Logical Operators in PHP And &...