Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * @author Jason
- * @copyright 2010
- */
- include "connect.php";
- $submit = $_POST['submit'];
- $username = mysql_real_escape_string( htmlspecialchars( strip_tags( addslashes( $_POST['username'] ) ) ) );
- $password = md5( mysql_real_escape_string( htmlspecialchars( strip_tags( addslashes( $_POST['password'] ) ) ) ) );
- $repeatpassword = md5( mysql_real_escape_string( htmlspecialchars( strip_tags( addslashes( $_POST['repeatpassword'] ) ) ) ) );
- if( isset( $submit ) )
- {
- $query = mysql_query(" SELECT * FROM users WHERE username = '$username' ");
- $numrows = mysql_num_rows( $query );
- if ( $numrows )
- {
- echo "Username is taken!";
- }
- if ( $username && $password && $repeatpassword )
- {
- if ( strlen( $username )>25 )
- {
- echo "Username must be within 25 characters!";
- }
- if ( strlen( $password )>25 && strlen( $password )<4 )
- {
- echo "Password must be between 4 to 25 characters!";
- }
- }
- else
- {
- echo "Please fill in all fields!";
- }
- }
- ?>
- <html>
- <form action='' method='POST'>
- Username: <input type="text" name="username"/><br />
- Password: <input type="password" name="password"/><br />
- Repeat Password: <input type="password" name="repeatpassword"/><br />
- <input type="submit" name="submit" value="Register"/>
- </form>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement