Advertisement
Guest User

Untitled

a guest
Sep 18th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.59 KB | None | 0 0
  1. <?
  2.  
  3. include 'connect.php'; //connect to mysql database
  4. include 'start.php';  //opening html for page
  5. function regdetails() {
  6.  
  7.     print "Register for an account on Bo-News:<br><br>
  8.         <form action='register.php' method='post'>
  9.         <table>
  10.             <tr>
  11.                 <td>Username:</td><td><input type='text' name='username'>
  12.             </tr>
  13.             <tr>
  14.                 <td>Password:</td><td><input type='password' name='password'>
  15.             </tr>
  16.             <tr>
  17.                 <td>Confirm Password:</td><td><input type='password' name='confirmpassword'>
  18.             </tr>
  19.             <tr>
  20.                 <td>Email:</td><td><input type='text' name='email'>
  21.             <tr>
  22.                 <td align='right'><input type='submit' value='register'>
  23.             </tr>
  24.             </table>
  25.             </form>";
  26.  
  27. }
  28.  
  29. //if we've tried to submit some data
  30. //make sure we've entered everything out properly
  31. if ($_POST['username'] != "") {
  32.     if ($_POST['password'] == "") { $error[$err] = "No password was entered!"; $err++; }
  33.     if ($_POST['confirmpassword'] == "") { $error[$err] = "You did not confirm your password!"; $err++; }
  34.     if ($_POST['confirmpassword'] != $_POST['password']) { $error[$err] = "Your passwords don't match!"; $err++; }
  35.     if ($_POST['email'] == "") { $error[$err] = "No email was entered!"; $err++; }
  36.     //check if email is a valid address
  37.    
  38.     if ($err == 0;) {
  39.         mysql_query("INSERT INTO users (username, password, email) VALUES('".$_POST['username']."','".$_POST['password']."','".$_POST['email']."' ) ") or die(mysql_error());
  40.     }
  41.     else {
  42.         print "<table>";
  43.         while ($i < $err) {
  44.             print "<tr><td>". $error[$i] ."</td></tr>";
  45.             $i++;
  46.         }
  47.         print "</table><br><br>";
  48.         regdetails();
  49.     }
  50. }
  51. else { regdetails(); }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement