Advertisement
Guest User

Untitled

a guest
May 18th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. <?php
  2. echo '<link href="style.css" rel="stylesheet" type="text/css"/>
  3. <div id="content" align="center"><h1>Register</h1>';
  4.  
  5. $hostname = "localhost";
  6. $username = "st2014";
  7. $dbname = "st2014";
  8. $password = "progress!";
  9.  
  10. if (isset($_REQUEST['attempt'])) {
  11.  
  12. $regusername = $_POST['username'];
  13. $regpassword = sha1($_POST['password']);
  14. $repeatpass = sha1($_POST['repeatpassword']);
  15. $realname = $_POST['realname'];
  16.  
  17. $con=mysqli_connect($hostname,$username,$password,$dbname);
  18. // Check connection
  19. if (mysqli_connect_errno())
  20. {
  21. echo "Failed to connect to MySQL: " . mysqli_connect_error();
  22. }
  23.  
  24. $result = mysqli_query($con,"SELECT * FROM t123891v1_users
  25. WHERE username='$regusername'");
  26. $rowname = "";
  27. while ($row = mysqli_fetch_array($result)) {
  28. $rowname = $row['username'];
  29. }
  30.  
  31. if($rowname == $regusername) {
  32. echo "User Already in Exists<br/>";
  33. } else {
  34. if($regpassword == $repeatpass) {
  35. mysql_connect($hostname, $username, $password) OR DIE ("Unable to
  36. connect to database! Please try again later.");
  37. mysql_select_db($dbname);
  38.  
  39. //Fetching from your database table.
  40. $query = "INSERT INTO `t123891v1_users` (`username`, `fullname` ,`password`) VALUES ('$regusername', '$realname', '$regpassword')";
  41. $result = mysql_query($query);
  42. echo "User Created!";
  43. echo '<META HTTP-EQUIV="Refresh" Content="1; URL=index.php">';
  44. exit();
  45. } else {
  46. echo '<br>Passwords didn\'t match, try again!';
  47. }
  48. }
  49. } else {
  50. echo 'Täitke järgnevad väljad!<br>';
  51. }
  52.  
  53. ?>
  54.  
  55. <html>
  56. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  57. <form action='register.php?attempt' method="POST">
  58. <table>
  59. <tr>
  60. <td>
  61. Your username:
  62. </td>
  63. <td>
  64. <input type='text' name='username'/>
  65. </td>
  66. </tr>
  67. <tr>
  68. <td>
  69. Your real name:
  70. </td>
  71. <td>
  72. <input type='text' name='realname'/>
  73. </td>
  74. </tr>
  75. <tr>
  76. <td>
  77. Your password:
  78. </td>
  79. <td>
  80. <input type='password' name='password'/>
  81. </td>
  82. </tr>
  83. <tr>
  84. <td>
  85. Repeat your password:
  86. </td>
  87. <td>
  88. <input type='password' name='repeatpassword'/>
  89. </td>
  90. </tr>
  91. <tr>
  92. <td>
  93. Your e-mail:
  94. </td>
  95. <td>
  96. <input type='text' name='email'/>
  97. </td>
  98. </tr>
  99. </table>
  100. <br>
  101. <input type='submit' name='submit' value='Register' />
  102. </form>
  103. </div>
  104. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement