Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (isset($_POST['submit']))
- {
- $submit = $_POST["submit"];
- $fullname = strip_tags($_POST["fullname"]);
- $username = strip_tags($_POST["username"]);
- $password = strip_tags($_POST["password"]);
- $repeatpassword = strip_tags($_POST["repeatpassword"]);
- $date = date("Y-m-d");
- if($submit)
- {
- //check for existence
- if($fullname&&$username&&$password&&$repeatpassword)
- {
- //check if passwords match
- if($password==$repeatpassword)
- {
- //check length of username
- if(strlen($fullname)>25||strlen($username)>25)
- {
- echo "max limit for username/fullname is 25 characters";
- }
- else
- {
- //check password length
- if((strlen($password)<6)||(strlen($password)>25))
- {
- echo "password must be between 6 and 25 characters";
- }
- else //register the user
- {
- //encrypt passwords
- $password = md5($password);
- $repeatpassword = md5($repeatpassword);
- //open database
- $connect = mysql_connect("localhost","root","rootpass");
- //select database
- mysql_select_db("phplogin");
- //insert data into the database
- $queryreg = mysql_query("INSERT INTO users (id,fullname,username,password,date) VALUES ('','".$fullname."','".$username."','".$password."','".$date."')");
- //notify user that they have been registered
- echo "registered<br><a href='index.php'>return to login page</a>";
- }
- }
- }
- else
- {
- echo "passwords do not match";
- }
- }
- else
- {
- echo "complete all fields to register<br>";
- }
- }
- }
- ?>
- <html>
- <head>
- <title></title>
- </head>
- <body>
- <h1>Register</h1>
- <form action='register.php' method='POST'>
- <table>
- <tr>
- <td>
- fullname:
- </td>
- <td>
- <input type='text' name='fullname'>
- </td>
- </tr>
- <tr>
- <td>
- username:
- </td>
- <td>
- <input type='text' name='username'>
- </td>
- </tr>
- <tr>
- <td>
- password:
- </td>
- <td>
- <input type='password' name='password'>
- </td>
- </tr>
- <tr>
- <td>
- repeat password:
- </td>
- <td>
- <input type='password' name='repeatpassword'>
- </td>
- </tr>
- <tr>
- <td>
- <!-- empty -->
- </td>
- <td align="right">
- <input type='submit' name='submit' value='register'>
- </td>
- </tr>
- </table>
- </form>
- </body>
- </html>
Add Comment
Please, Sign In to add comment