Advertisement
Guest User

Untitled

a guest
Dec 1st, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Php Login</title>
  6. </head>
  7.  
  8. <body>
  9.  
  10.  
  11. <form action="checkuserlogin.php" method="post">
  12. Username: &nbsp;
  13. <input type="text" name="uname">
  14.  
  15. <br/>
  16. <br/>
  17.  
  18. Password: &nbsp;
  19. <input type="password" name="pword">
  20.  
  21. <br />
  22. <br />
  23.  
  24. Name: &nbsp;
  25. <input type="text" name="name">
  26.  
  27. <br />
  28. <br />
  29.  
  30. Gender: &nbsp;
  31.  
  32. <br />
  33. <input type="radio" name="gender" value="Male">Male<br />
  34. <input type="radio" name="gender" value="Female">Female
  35.  
  36. <br />
  37. <br />
  38.  
  39. Date of Submission: &nbsp;
  40. <input type="datetime" name="submissiondate">
  41.  
  42. <br />
  43. <br />
  44.  
  45. <input type="submit" value="Login" name="save">
  46.  
  47. </form>
  48.  
  49.  
  50. <?php
  51.  
  52. if(isset($_GET['uname']) && isset($_GET['pword']))
  53. {
  54. echo "<b>Invalid Username and Password</b>";
  55. }
  56. ?>
  57.  
  58.  
  59. </body>
  60. </html>
  61.  
  62. <!doctype html>
  63. <html>
  64. <head>
  65. <meta charset="utf-8">
  66. <title>Check User Login</title>
  67. </head>
  68.  
  69. <body>
  70. <?php
  71.  
  72. $u=$_POST['uname'];
  73. $p=$_POST['pword'];
  74. $u=$_POST['uname'];
  75. $p=$_POST['pword'];
  76. $u=$_POST['uname'];
  77. $p=$_POST['pword'];
  78. $n=$_POST['name'];
  79. $g=$_POST['gender'];
  80. date_default_timezone_set('Asia/Singapore');
  81. $time=date('Y-m-d H:i:s');
  82. $s=$time . $_POST['submissiondate'];
  83.  
  84. $conn=mysqli_connect("localhost", "root", "" , "db_healthcare");
  85. $sql="INSERT INTO users_care(uname, pword, name, gender, submissiondate) VALUES ('$u' , '$p', '$n' , '$g' , '$s')";
  86. $result=mysqli_query($conn, $sql);
  87. if($result)
  88. {
  89. echo "Data Saved";
  90. }
  91. else
  92. {
  93. echo "Not Saved";
  94. }
  95.  
  96.  
  97. mysqli_close($conn);
  98.  
  99. ?>
  100.  
  101. <?php
  102. if(isset($_POST["uname"]))
  103. {
  104. $u=$_POST['uname'];
  105. $p=$_POST['pword'];
  106.  
  107. $query = "SELECT * FROM users_care WHERE uname='" .$u. "' AND pword='" .$p. "' ";
  108. $search_result=mysqli_query($conn, $query);
  109.  
  110. $userfound=mysqli_num_rows($search_result);
  111.  
  112.  
  113. if($userfound >= 1)
  114. {
  115. header("Location: success.html");
  116. }
  117. else
  118. {
  119. header("Location: login.php?uname=" . $u . "&pw=" . $p);
  120. }
  121.  
  122.  
  123. }
  124.  
  125. mysqli_close($conn);
  126. ?>
  127.  
  128.  
  129. </body>
  130. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement