Advertisement
Guest User

Untitled

a guest
Jun 8th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. Register Php
  2.  
  3. <?php
  4. session_start();
  5. $_SESSION['message']='';
  6. $mysqli=new MySQLi('127.0.0.1','root','','accounts');
  7.  
  8.  
  9.  
  10. if(isset($_POST['login'])) {
  11. $username = $mysqli->real_escape_string($_POST['username']);
  12. $password = md5($_POST['password']);
  13. $sql="SELECT * FROM users WHERE username='$username' AND password='$password' LIMIT 1;";
  14. $result = mysqli_query($mysqli,$sql);
  15.  
  16. if(mysqli_num_rows($result) > 0){
  17. $row = mysqli_fetch_array($result);
  18.  
  19. if (($row['username']=='sithi')&&($row['password']=='202cb962ac59075b964b07152d234b70')){
  20. $_SESSION['user_type'] = $row;
  21. $_SESSION['password'] = $row;
  22. $_SESSION['message'] = "Registration successful!";
  23. header("location:myresuming.html");exit();
  24. }
  25. else{
  26.  
  27. $_SESSION['username'] = $row['username'];
  28. $_SESSION['profile'] = $row['profile'];
  29. $_SESSION['message'] = "Registration successful!";
  30. header("location:Welcome.php");exit();
  31. }
  32. }
  33. else{
  34. $_SESSION['message'] = "Login Failed!";
  35. }
  36.  
  37. }
  38.  
  39.  
  40.  
  41. ?>
  42.  
  43. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  44. <html xmlns="http://www.w3.org/1999/xhtml">
  45. <head>
  46. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  47. <title>form in Design</title>
  48. <link rel="stylesheet" type="text/css" href="mystyle.css" />
  49. <link rel="stylesheet" type="text/css" href="form.css" />
  50. </head>
  51. <body>
  52. <div class="container"><?=$_SESSION['message']?>
  53. <img src="5.jpg" />
  54. <form class="form" action="" method="post" enctype="multipart/form-data" autocomplete="off">
  55. <div class="alert alert-error"></div>
  56. <input type="text" placeholder="User Name" name="username" required />
  57. <input type="password" placeholder="Password" name="password" autocomplete="new-password" required />
  58. <input type="submit" name="login" value="login" class="btn-login" />
  59.  
  60. </form>
  61. </div>
  62. </body>
  63. </html>
  64.  
  65. <?php
  66. session_start();
  67. $_SESSION['message'] = '';
  68. $mysqli=new MySQLi('127.0.0.1','root','','learning_malaysia');
  69. if(isset($_POST['login'])) {
  70. $username = $mysqli->real_escape_string($_POST['username']);
  71. $password = md5($_POST['password']);
  72. $sql="SELECT*FROM tutor_register WHERE username ='$username' AND password ='$password'";
  73. $result = mysqli_query($mysqli,$sql) or die(mysql_error());
  74. $row = mysqli_num_rows ($result);
  75.  
  76. if(mysqli_num_rows($result) > 0){
  77. $row = mysqli_fetch_array($result);
  78. $_SESSION['username'] = $username;
  79. header("location:class.php");
  80. }
  81.  
  82. else{
  83. $_SESSION['message'] = "Login Failed!";
  84.  
  85. }
  86. }
  87. ?>
  88.  
  89.  
  90. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  91. <html xmlns="http://www.w3.org/1999/xhtml">
  92. <head>
  93. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  94. <title>Untitled Document</title>
  95. </head>
  96.  
  97. <body>
  98. <?=$_SESSION['message']?>
  99. <form class="form" action="" method="post" enctype="multipart/form-data" autocomplete="off">
  100. <div class="alert alert-error"></div>
  101. <input type="text" placeholder="User Name" name="username" required />
  102. <input type="password" placeholder="Password" name="password" autocomplete="new-password" required />
  103. <input type="submit" name="login" value="login" class="btn-login" />
  104.  
  105. </body>
  106. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement