Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.31 KB | None | 0 0
  1. <?php
  2.  
  3. echo "<h1>Register</h1>";
  4.  
  5.  
  6.  
  7. $submit = strip_tags($_POST['submit']);
  8.  
  9. $name = strip_tags($_POST['name']);
  10.  
  11. $email = strip_tags($_POST['email']);
  12.  
  13. $username = strip_tags($_POST['username']);
  14.  
  15. $password = strip_tags($_POST['password']);
  16.  
  17. $password2 = strip_tags($_POST['password2']);
  18.  
  19. $date = date("Y-m-d");
  20.  
  21.  
  22.  
  23. if ($submit) {
  24.  
  25.    
  26.  
  27.     // check if user is already in database
  28.  
  29.    
  30.  
  31.     // check for existance
  32.  
  33.     if ($username&&$password&&$password2&&$name&&$email) {
  34.  
  35.        
  36.  
  37.         // encrypt password
  38.  
  39.        
  40.  
  41.        
  42.  
  43.         // check if passwords match
  44.  
  45.         if ($password==$password2) {
  46.  
  47.            
  48.  
  49.             //check if password is too small
  50.  
  51.             if (strlen($password)<6) {
  52.  
  53.                 echo "Password must be longer then 6 chars";
  54.  
  55.             } else {
  56.  
  57.                 $password = md5($password);
  58.  
  59.                 $password2 = md5($password2);
  60.  
  61.                
  62.  
  63.                 // Open Database
  64.  
  65.                 $connect = mysql_connect("mysql.freezoka.net","u436088065_helge ","toribash123") or die(mysql_error());
  66.  
  67.                 mysql_select_db("u436088065_phplogin") or die(mysql_error());
  68.  
  69.                
  70.  
  71.                 $query = mysql_query("INSERT INTO users VALUES('','$username','$password','$name','$date','$email')");
  72.  
  73.                 die("User $username has been registered!<br /> <a href='index.php'>Click here</a> to log in!");
  74.  
  75.                
  76.  
  77.             }
  78.  
  79.            
  80.  
  81.         } else {
  82.  
  83.             echo "Your passwords does not match!";
  84.  
  85.             }
  86.  
  87.        
  88.  
  89.        
  90.  
  91.     } else {
  92.  
  93.         echo "Please fill in all the fields!";
  94.  
  95.     }
  96.  
  97.    
  98.  
  99. }
  100.  
  101.  
  102.  
  103. ?>
  104.  
  105.  
  106.  
  107.  
  108.  
  109. <html>
  110.  
  111. <head>
  112.  
  113. <title>Register</title>
  114.  
  115. </head>
  116.  
  117. <body>
  118.  
  119. </p>
  120.  
  121. <form action="register.php" method="POST">
  122.  
  123.     <table border="0">
  124.  
  125.         <tr>
  126.  
  127.             <td>Name:</td>
  128.  
  129.             <td><input type="text" maxlength="40" name="name" value="<?php echo $name; ?>" /></td>
  130.  
  131.         </tr>
  132.  
  133.         <tr>
  134.  
  135.             <td>Email:</td>
  136.  
  137.             <td><input type="text" maxlength="60" name="email" value="<?php echo $email; ?>" /></td>
  138.  
  139.         </tr>
  140.  
  141.         <tr>
  142.  
  143.             <td>Username:</td>
  144.  
  145.             <td><input type="text" maxlength="20" name="username" value="<?php echo $username; ?>" /></td>
  146.  
  147.         </tr>
  148.  
  149.         <tr>
  150.  
  151.             <td>Password:</td>
  152.  
  153.             <td><input type="password" name="password" /></td>
  154.  
  155.         </tr>
  156.  
  157.         <tr>
  158.  
  159.             <td>Password Again:</td>
  160.  
  161.             <td><input type="password" name="password2" /></td>
  162.  
  163.         </tr>
  164.  
  165.         <tr>
  166.  
  167.             <td colspan="2"> <input type="submit" value="Register!" name="submit" />
  168.  
  169.         </tr>
  170.  
  171.     </table>
  172.  
  173. </form>
  174.  
  175. </body>
  176.  
  177. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement