Advertisement
MadhujitB

Untitled

May 21st, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang = "en">
  3. <head>
  4. <title>LogIn Form</title>
  5. </head>
  6. <body>
  7. <div>
  8. <form name = "signin" action = "ValidateSignIN.php" method="post">
  9. <div>
  10. <label for = "">User Name/Email ID:</label>
  11. <input type="text" name = "une"></input>
  12. </div>
  13.  
  14. <div>
  15. <label for = "">Passowrd:</label>
  16. <input type="password" name="pswd"></input>
  17. </div>
  18.  
  19.  
  20. <div>
  21. <input type="submit" value = "SignIN"></input>
  22. <button type="reset">Clear</input>
  23.  
  24. </div>
  25. </form>
  26. </div>
  27. </body>
  28. </html>
  29.  
  30. -----------------------------------------------------PHP MySQL Page--------------------------------------------------------------
  31.  
  32. //ValidateSignIN.php
  33. <!DOCTYPE html>
  34. <html>
  35. <head>
  36. <title>LogINReply</title>
  37. </head>
  38. <body>
  39. <?php
  40.  
  41. $servername = "localhost";
  42. $username = "root";
  43. $password = "";
  44. $dbname = "movies";
  45. $unameormail = $_POST["une"];
  46. $passwd = $_POST["pswd"];
  47.  
  48.  
  49. /*if($passwd === $cnfpasswd)
  50.  
  51. {*/
  52.  
  53. // Create connection
  54.  
  55. $conn = new mysqli($servername, $username, $password, $dbname);
  56.  
  57. // Check connection
  58.  
  59. if ($conn->connect_error)
  60. {
  61.  
  62. die("Connection failed: " . $conn->connect_error);
  63.  
  64. }
  65.  
  66. $sql = "SELECT * FROM users WHERE UNAMEORMAIL='$unameormail' AND PASSWORD='$passwd'";
  67.  
  68. //Whenever I tried to execute the below code, it executes the else part. Though both username and password exist in the //database. Is this the right technique or I have to use something different.
  69. if ($conn->query($sql) === TRUE)
  70. {
  71.  
  72. echo "<p>WELCOME</p>";
  73.  
  74. }
  75.  
  76. else
  77.  
  78. {
  79.  
  80. echo "Error updating record: " . $conn->error;
  81. }
  82.  
  83. $conn->close();
  84.  
  85.  
  86. ?>
  87. </body>
  88. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement