Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // If the form hasn't been submitted yet
- if (!isset($_POST['username'])) {
- // Echo the form. Customize this how you please
- echo "<form method=post action=register.php>";
- echo "Username: <input type=text name=username><br>";
- echo "Password: <input type=password name=password><br>";
- echo "<input type=submit value=Register>";
- echo "</form>";
- // If the form has been submitted
- }else{
- // FILL THIS IN WITH YOUR DATABASE INFO
- $db_host = 'localhost';
- $db_user = '';
- $db_name = '';
- $db_pass = '';
- $tbl_name = '';
- // Connect to the database
- mysql_connect($db_host, $db_user, $db_pass) or die ('Cannot Connect Database');
- mysql_select_db($db_name) or die ('Cannot Select Database');
- // Randomly generate an id
- $id = rand();
- // Run the query into the database
- mysql_query("INSERT INTO `".$tbl_name."` VALUES (".$id.", '".mysql_real_escape_string($_POST['username'])."', '".mysql_real_escape_string($_POST['password'])."');");
- // Echo the complete message. Customize this as you please
- echo "Registration Complete";
- }
- ?>
Add Comment
Please, Sign In to add comment