Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <basefont face="Arial">
- </head>
- <body>
- <?php
- if (!isset($_POST['submit'])) {
- // form not submitted
- ?>
- <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
- <center><b>Register new user (Login v0.3 by Silence)</b><br /></center>
- <hr>
- <b>Username:</b> <input type="text" name="username">
- <b>Password:</b> <input type="text" name="passwdclear">
- <input type="submit" name="submit" value="Register">
- </form>
- <?php
- }
- else {
- // form submitted
- // set server access variables & salt
- $host = "localhost"; // This is your hostname.
- $user = "root"; // This is your MySQL username.
- $pass = "akecbdy6"; // This is your MySQL password.
- $db = "passwd"; // This is the name of the database (line 47).
- $salt = "mysalt"; // This is set for crypting (line 50).
- $table = "details"; // This is the name of the table (line 53)
- // get form input
- // check to make sure it's all there
- // escape input values for greater safety
- $username = empty($_POST['username']) ? die ("ERROR: Enter a username") : mysql_escape_string($_POST['username']);
- $passwdclear = empty($_POST['passwdclear']) ? die ("ERROR: Enter a password") : mysql_escape_string($_POST['passwdclear']);
- // open connection
- $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
- // select database
- mysql_select_db($db) or die ("Unable to select database!");
- // crypt before entry into DB
- $password = crypt($passwdclear, $salt);
- // create query
- $query = "INSERT INTO $table (username, password) VALUES ('$username', '$password')";
- // execute query
- $result = mysql_query($query) or die ("<b> Registration unsuccessful.. <br /> </b> Raw error supplied by MySQL:<br /><br /> $query. ".mysql_error());
- // print message with ID of inserted record
- //echo "New record inserted with ID ".mysql_insert_id();
- // print message with ID of created user
- echo "<b> Registration Successful! </b>";
- echo "<hr>";
- echo "New user created with ID ".mysql_insert_id(). "<br />";
- echo "<b>Username:</b> $username <br/>";
- echo "<b>Password:</b> $passwdclear <br/>";
- echo "<hr>";
- // close connection
- mysql_close($connection);
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement