Arslan Ali

Arslan Ali

  • NA
  • 69
  • 11.6k

Post method not working

Jul 8 2018 12:40 AM
hi , i have a simple form in and i am using post method to pass textbox values to second page , but the post method doesnt seem to work at all , i tried almost evrything but it is not working , i need help
  1. <form action="index.php" method="POST">  
  2. <table>  
  3. <tr>  
  4. <td><label>Username</label></td>  
  5. <td><input type="text" name="uname"/></td>  
  6. </tr>  
  7. <tr>  
  8. <td><label>Password</label></td>  
  9. <td><input type="password" name="pword"/></td>  
  10. </tr>  
  11. <tr>  
  12. <td><label>Confirm Password</label></td>  
  13. <td><input type="password" name="cpword"/></td>  
  14. </tr>  
  15. </table>  
  16. <input type="submit" Value="Login"/>  
  17. </form>  
and below is the second php file (where i am trying to acces POST)
  1. <?php  
  2. if(isset($_POST["uname"]))  
  3. $usernamep = $_POST["uname"];  
  4. echo "$username";  
  5. }  
  6. if(isset($_POST["pword"]))  
  7. $passwordp = $_POST["pword"];  
  8. if(isset($_POST["cpword"]))  
  9. $confirmp = $_POST["cpword"];  
  10. $connection = mysqli_connect('localhost','something','something','collegedb');  
  11. if(!$connection)  
  12. {  
  13. die("some problem occured while connecting.");  
  14. }  
  15. $query = "select * from users where UserName='".$usernamep."'and UserPassword='".$passwordp."'";  
  16. $result = mysqli_query($connection,$query);  
  17. if(mysqli_num_rows($result)>0)  
  18. {  
  19. session_start();  
  20. $_SESSION['currentuser'] = $usernamep;  
  21. header('Location:http://localhost/home/');  
  22. }  
  23. else  
  24. echo "No Rows Found !";  
  25. ?>  
here is the error my chrome shows :>
 
Notice: Undefined variable: usernamep in C:\xampp\htdocs\home\index.php on line 20
 
Notice: Undefined variable: passwordp in C:\xampp\htdocs\home\index.php on line 20
 
No Rows Found !

Answers (1)