Share Pastebin
Guest
Public paste!

register.php

By: a guest | Mar 21st, 2010 | Syntax: HTML | Size: 1.31 KB | Hits: 293 | Expires: Never
Copy text to clipboard
  1.    <html>
  2.          <head>
  3.     <body background="http://www.wallpaperweb.org/wallpaper/Games/1920x1200/deathwing_1920x1200.jpg"/>
  4.           <?php
  5.  
  6.  
  7. include ("dbConfig.php");
  8.  
  9.  
  10.  
  11. if ( $_GET["op"] == "reg" )
  12. {
  13. $bInputFlag = false;
  14. foreach ( $_POST as $field )
  15.  {
  16.  if ($field == "")
  17.   {
  18.   $bInputFlag = false;
  19.   }
  20.  else
  21.   {
  22.   $bInputFlag = true;
  23.   }
  24.  }
  25.  
  26. if ($bInputFlag == false)
  27.  {
  28.  die( "Problem with your registration info. "
  29.   ."Please go back and try again.");
  30.  }
  31.  
  32.  
  33. $q = "INSERT INTO `dbUsers` (`username`,`password`,`email`) "
  34.  ."VALUES ('".$_POST["username"]."', "
  35.  ."PASSWORD('".$_POST["password"]."'), "
  36.  ."'".$_POST["email"]."')";
  37. $r = mysql_query($q);
  38.  
  39.  
  40. if ( !mysql_insert_id() )
  41.  {
  42.  die("Error: User not added to database.");
  43.  }
  44. else
  45.  {
  46.  
  47.  Header("Location: register.php?op=thanks");
  48.  }
  49. }
  50.  
  51.  
  52.  
  53. elseif ( $_GET["op"] == "thanks" )
  54. {
  55. echo "<h2>Thanks for registering!</h2>";
  56.  }
  57.  
  58.  
  59. else
  60.  {
  61.  echo "<form action=\"?op=reg\" method=\"POST\">\n";
  62.  echo "Username: <input name=\"username\" MAXLENGTH=\"16\"><br />\n";
  63.  echo "Password: <input type=\"password\" name=\"password\" MAXLENGTH=\"16\"><br />\n";
  64.  echo "Email Address: <input name=\"email\" MAXLENGTH=\"25\"><br />\n";
  65.  echo "<input type=\"submit\">\n";
  66.  echo "</form>\n";
  67.  }
  68. ?>
  69.  </body>
  70.  </html>