Advertisement
Guest User

Untitled

a guest
Jun 7th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.82 KB | None | 0 0
  1. <center>
  2. <form action="<?php $_SERVER['PHP_SELF'] ?>" method ="POST">
  3.     <table>
  4.         <tr>
  5.             <td class=list align=right><p>User ID: </p></td>
  6.             <td class=list><input type=text name=username maxlength="12"></td>
  7.         </tr>
  8.         <tr>
  9.             <td class=list align=right><p>Password: </p></td>
  10.             <td class=list><input type=password name=pass maxlength="12"></td>
  11.         </tr>
  12.         <tr>    
  13.             <td class=list align=right><p>Retype Password: </p></td>
  14.             <td class=list><input type=password name=vpass maxlength="12"></td>
  15.         </tr>
  16.         <tr>
  17.             <td class=list align=right><p>Email: </p></td>
  18.             <td class=list><input type=text name=email maxlength="50"></td>
  19.         </tr>
  20.         <tr>    
  21.                 <td class=list align=right><p>Birthdate: <br><font size="1"><i></i></font></p></td>
  22.                 <td class=list><input type=text name=dob maxlength="15"></td>
  23.         </tr>
  24.         <tr>
  25.         <br><td><input align = "center" type="submit" name = "sub" value="Complete registration" />
  26.         </tr>
  27. </form></center>
  28.  
  29. <?php
  30. if(isset($_POST['sub'])){
  31.  
  32.     $username = addslashes($_POST['username']);
  33.     $password = $_POST['pass'];
  34.     $password2 = $_POST['vpass'];
  35.     $email = addslashes($_POST['email']);
  36.     $birthdate = addslashes($_POST['dob']);
  37.  
  38.     $dbhost = "localhost"; // put your host here
  39.     $dbuser= "root"; // db user here
  40.     $dbpass= ""; //dbpass here
  41.     $dbname= "test";
  42.     $table= "giac_test"; //table name here
  43.    
  44.     mysql_connect("localhost", "root", "") or die ("error");
  45.     mysql_select_db("test") or die ("Error with db!");
  46.    
  47.     $error = array();
  48.         if (empty($username))
  49.             $error[] = "You must enter a username. <br/>";
  50.         if (empty($password))
  51.             $error[] = "You must enter a password. <br/>";
  52.         if (empty($password2))
  53.             $error[] = "Please enter your password a second time. <br/>";
  54.         if (empty($email))
  55.             $error[] = "You must enter an email address. <br/>";
  56.         if (empty($birthdate))
  57.             $error[] = "You must enter your BirthDate. <br/>";
  58.         if ($password != $password2){
  59.             $error[] = "Your passwords do not match!<br/>";
  60.         }
  61.     foreach ($error as $err){    
  62.        
  63.            
  64.         echo $err;    
  65.         if (!$err){
  66.            
  67.             mysql_query("INSERT INTO $table (`id`, `username`, `password`, `email`, `date`) VALUES (
  68.                        '',
  69.                        '".$username."',
  70.                        '".md5($password)."',
  71.                        '".$email."',
  72.                        '".time()."'
  73.                        )") or die(mysql_error());
  74.     echo "Registration Successful!";
  75.        
  76.         }else
  77.     echo "Fail";    
  78.    
  79.   }
  80.   }
  81.  
  82.  
  83.  
  84. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement