Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- $host="localhost";
- $username="zaccyb_admin";
- $password="Strawrats661";
- $dbname="zaccyb_users";
- $tblename="users";
- mysql_connect("$host", "$username", "$password")or die("Cannot connect");
- mysql_select_db("$dbname")or die("cannot select DB");
- $nusername = $_POST['username'];
- $npassword = $_POST['password'];
- $nvpassword = $_POST['vpassword'];
- $nusername = stripslashes($nusername);
- $npassword = stripslashes($npassword);
- $nusername = mysql_real_escape_string($nusername);
- $npassword = mysql_real_escape_string($npassword);
- $Vusername= " SELECT * FROM $tblename WHERE username = '$nusername'";
- $userResult = mysql_query($Vusername);
- $count = mysql_num_rows($userResult);
- if ($count >= 1)
- {
- echo "That username is already taken";
- ?>
- <br /><br />
- <form name="input" action="registersuccess.php" method="post" id="user" >
- Username: <input type="text" name="username" autocomplete="off" /> <br /><br />
- Password: <input type="password" name="password" autocomplete="off" /> <br /><br />
- Re type password: <input type="password" name="vpassword" autocomplete="off" /> <br /><br />
- <input type="submit" value="Submit" />
- </form>
- <?
- }
- else if ($npassword != $nvpassword)
- {
- echo "Passwords didn't match";
- ?>
- <br /><br />
- <form name="input" action="registersuccess.php" method="post" id="user" >
- Username: <input type="text" name="username" autocomplete="off" /> <br /><br />
- Password: <input type="password" name="password" autocomplete="off" /> <br /><br />
- Re type password: <input type="password" name="vpassword" autocomplete="off" /> <br /><br />
- <input type="submit" value="Submit" />
- </form>
- <?
- }
- else if ($nusername == null || $npassword == null)
- {
- echo "Username or password cannot be left empty";
- ?>
- <br /><br />
- <form name="input" action="registersuccess.php" method="post" id="user" >
- Username: <input type="text" name="username" autocomplete="off" /> <br /><br />
- Password: <input type="password" name="password" autocomplete="off" /> <br /><br />
- Re type password: <input type="password" name="vpassword" autocomplete="off" /> <br /><br />
- <input type="submit" value="Submit" />
- </form>
- <?
- }
- else
- {
- $sql="INSERT INTO $tblename(username, password)
- VALUES ('$nusername', '$npassword')";
- $result = mysql_query($sql);
- echo "AWESOME!";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement