Guest User

Untitled

a guest
Oct 15th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.06 KB | None | 0 0
  1. <?php
  2.  
  3. // If the form hasn't been submitted yet
  4. if (!isset($_POST['username'])) {
  5.  
  6.     // Echo the form. Customize this how you please
  7.     echo "<form method=post action=register.php>";
  8.     echo "Username: <input type=text name=username><br>";
  9.     echo "Password: <input type=password name=password><br>";
  10.     echo "<input type=submit value=Register>";
  11.     echo "</form>";
  12.  
  13. // If the form has been submitted
  14. }else{
  15.  
  16.     // FILL THIS IN WITH YOUR DATABASE INFO
  17.     $db_host = 'localhost';
  18.     $db_user = '';
  19.     $db_name = '';
  20.     $db_pass = '';
  21.     $tbl_name = '';
  22.  
  23.     // Connect to the database
  24.     mysql_connect($db_host, $db_user, $db_pass) or die ('Cannot Connect Database');
  25.     mysql_select_db($db_name) or die ('Cannot Select Database');
  26.    
  27.     // Randomly generate an id
  28.     $id = rand();
  29.  
  30.     // Run the query into the database
  31.     mysql_query("INSERT INTO `".$tbl_name."` VALUES (".$id.", '".mysql_real_escape_string($_POST['username'])."', '".mysql_real_escape_string($_POST['password'])."');");
  32.    
  33.     // Echo the complete message. Customize this as you please
  34.     echo "Registration Complete";
  35.  
  36. }
  37.  
  38. ?>
Add Comment
Please, Sign In to add comment