I have a register code, and if the username is taken, currently, it takes them to another page to say the username is taken.
Is it possible to do a javascript popup box if the username is taken? here is register.php
<?php
if($_POST["username"] && $_POST["password"] && $_POST["password2"] )
{
$username = $_POST["username"];
$password = $_POST["password"];
$password2 = $_POST["password2"];
if($password==$password2)
{
$password = md5($password);
$DBservername="localhost";
$DBusername="******";
$DBpassword="******";
$conn = mysql_connect($DBservername,$DBusername,$DBpassword)or die(mysql_error());
mysql_select_db("gogreen",$conn);
$dbunames = mysql_query("SELECT * FROM `members` WHERE username='$username'");
if(mysql_num_rows($dbunames) > 0 ) {
echo "Username Taken!";
} else {
$sql="INSERT INTO `members` (username,password)values('$username','$password')";
$result=mysql_query($sql,$conn) or die(mysql_error());
print "<h1>you have registered sucessfully</h1>";
header("Location: ../index.php");
}
}
else print "Passwords doesnt match";
}
?>