Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include "includes/connect.php";
- $username = $_POST['username'];
- $email = $_POST['email'];
- $location = $_POST['location'];
- ?>
- <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST">
- Username:
- <input type="text" name="username" value="<?php echo $username; ?>" />
- <br>
- Email:
- <input type="text" name="email" value="<?php echo $email; ?>" />
- <br>
- Password:
- <input type="password" name="password1" />
- <br>
- Password(again):
- <input type="password" name="password2" />
- <br>
- Location:
- <input type="text" name="location" value="<?php echo $location; ?>" />
- <br />
- <?php
- $ip=$_SERVER['REMOTE_ADDR'];
- ?>
- Ip: <strong><?php echo "$ip" ?></strong><br />
- <br />
- <input name="terms" type="checkbox">
- I agree the Terms and Conditions <br />
- <br />
- <input type="submit" name="submit" value="Register!" />
- </form>
- <?php
- $username = mysql_real_escape_string($_POST['username']);
- $email = mysql_real_escape_string($_POST['email']);
- $password1 = mysql_real_escape_string($_POST['password1']);
- $password2 = $_POST['password2'];
- $location = mysql_real_escape_string($_POST['location']);
- $terms = mysql_real_escape_string($_POST['terms']);
- $userchecker = mysql_query("select * from users where username='$username'");
- $userchecker2 = mysql_num_rows($userchecker);
- $namelength = strlen($username);
- if(isset($_POST['username']))
- {
- if($password1 != $password2)
- {
- echo "Your passwords do not match!";
- }
- elseif($terms != on)
- {
- echo "You must agree before you can continue!";
- }
- elseif($namelength < 3)
- {
- echo "Your Username must be longer than 3 characters!";
- }
- elseif($userchecker2 > 0)
- {
- echo "Username is taken!";
- }
- else
- {
- $password = md5($password1);
- $result = mysql_query("INSERT INTO users (username, password, email, location) VALUES ('$username', '$password', '$email', '$location')");
- if($result)
- {
- echo "Success!";
- ////////
- echo "<br />";
- echo $ip;
- ///////
- }
- else
- {
- echo "There was a Database error";
- }
- }
- }
- ?>
Add Comment
Please, Sign In to add comment