Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- echo "<h1>Register</h1>";
- $submit = $_POST[submit];
- //form data
- $fullname = strip_tags($_POST['fullname']);
- $username = srtolower(strip_tags($_POST['username']));
- $password = strip_tags($_POST['password']);
- $repeatpassword = strip_tags($_POST['repeatpassword']);
- $date = date("Y-m-d");
- if ($submit)
- {
- //open database
- $connect = mysql_connect("localhost","root","");
- mysql_select_db("itzlghts_files"); //select database
- $namecheck = mysql_query("SELECT username FROM users WHERE username='$username'");
- $count = mysql_num_rows($namecheck);
- if($count!=0))
- {
- die("Username is already in use!");
- }
- //check for excistance
- if ($fullname&&$username&&$password&&$repeatpassword)
- {
- if ($password==$repeatpassword)
- {
- //check char lenth of username and full name
- if (strlen($username)>25||strlen($fullname)>25)
- {
- echo "Length of username or full name is too long!"
- }
- else
- {
- //check password lenth
- if (strlen$password)>25||strlen($password)<6)
- {
- echo "Password must be between 6 and 25 characters."
- }
- else
- {
- //register the user!
- //encrypt password
- $password = md5($password);
- $repeatpassword = md5($repeatpassword);
- $queryreg = mysql_query("
- INSERT INTO users VALUES (''', '$fullname', '$username', '$password', '$date')
- ");
- die("You have been registered! ,<a href='index.php'>Return to login page</a>");
- }
- }
- }
- else
- echo "Your passwords do not match!";
- }
- else
- else "Please fill in <b>all</b> fields!";
- }
- ?>
- <html>
- <p>
- <form action='register.php' method='POST'>
- <table>
- <tr>
- <td>
- Your full name:
- </tb>
- <td>
- <input type='text' name='fullname' value='<?php echo $fullname; ?>'>
- </td>
- </tr>
- <tr>
- <td>
- Choose a username:
- </tb>
- <td>
- <input type='text' name='username' value='<?php echo $username; ?>'>
- </td>
- </tr>
- <tr>
- <td>
- Choose a password:
- </tb>
- <td>
- <input type='password' name='password'>
- </td>
- </tr>
- <tr>
- <td>
- Repeat your password:
- </tb>
- <td>
- <input type='password' name='repeat password'>
- </td>
- </tr>
- </table>
- <p>
- <input type='submit' name='submit' value='Register'>
- </form>
- </html>
Add Comment
Please, Sign In to add comment