Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- echo "<h1>Register</h1>";
- $submit = $_POST['submit'];
- // form data
- $name = strip_tags($_POST['name']);
- $lastname = strip_tags($_POST['lastname']);
- $username = strtolower(strip_tags($_POST['username']));
- $password = strip_tags($_POST['password']);
- $rpassword = strip_tags($_POST['rpassword']);
- $email = strip_tags($_POST['email']);
- $age = strip_tags($_POST['age']);
- $date = date("Y-m-d");
- if ($submit)
- {
- //open database
- $connect = mysql_connect("localhost", "erik", "eriper56");
- mysql_select_db("exann"); //select database
- //check if usernane exist
- $namecheck = mysql_query("SELECT username FROM login WHERE username='$username'");
- $count = mysql_num_rows($namecheck);
- if($count!=0)
- {
- die("Username already taken!");
- }
- //check for existance
- if ($username&&$password&&$name&&$email&&$age&&$rpassword&&$lastname)
- {
- //check username and fullname length
- if (strlen($username) > 25)
- {
- echo "Max limit for usernamne are 25 charecters";
- }
- else
- {
- //check password length
- 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);
- //what goes in to the database
- $queryreg = mysql_query("INSERT INTO login VALUES ('','$name','$lastname','$username','$password','$email','$age','$date')") or die(mysql_error());
- die("You have been registrered! <a href='index.html'>Return to login page</a>");
- }
- }
- }
- else
- echo "Please fill in <b>all</b> fields!";
- }
- ?>
- <htlm>
- <p>
- <form action="register.php" method="post">
- <table>
- <tr>
- <td>
- <?php echo utf8_decode("Förnamn:"); ?>
- </td>
- <td>
- <input type="text" name="name" value="<?php echo $name ?>" />
- </td>
- </tr>
- <tr>
- <td>
- Efternamn:
- </td>
- <td>
- <input type="text" name="lastname" value="<?php echo $lastname ?>" />
- </td>
- </tr>
- <tr>
- <td>
- Username:
- </td>
- <td>
- <input type="text" name="username" value="<?php echo $username ?>" />
- </td>
- </tr>
- <tr>
- <td>
- Password
- </td>
- <td>
- <input type="password" name="password" />
- </td>
- </tr>
- <tr>
- <td>
- Password igen:
- </td>
- <td>
- <input type="password" name="rpassword" />
- </td>
- </tr>
- <tr>
- <td>
- Email:
- </td>
- <td>
- <input type="text" name="email" value="<?php echo $email ?>" />
- </td>
- </tr>
- <tr>
- <td>
- <?php echo utf8_decode("Ålder:"); ?>
- </td>
- <td>
- <input type="text" name="age" value="<?php echo $age ?>" />
- </td>
- </tr>
- </table>
- <input type="submit" name"submit" value="Regestrate" />
- </form>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement