Hi there, how do I link these two PHP codes together?
and
Code:
<?php
$conn = mysql_connect("localhost", "root", "jhdyjkkaj");
$db = mysql_select_db("cq");
if(isset($_POST['submit']))
{
if(isset($_POST['pass']) && $_POST['pass'] != "")
{
if($_POST['pass'] == $_POST['pass2'])
{
if(strlen($_POST['pass']) > 3 && strlen($_POST['pass']) < 32)
{
$sql = "INSERT INTO `accounts` (Username, Password) VALUES ('".$_POST['username']."', '".$_POST['pass']."')";
$sql = mysql_query($sql);
echo "Registered Successfully, use your browser to go back.";
} else {
die("Your password must be between 3 and 32 characters.");
}
} else {
die("Your passwords do not match.");
}
} else {
die("Please enter in a password.");
}
}
?>
and
Code:
$username = $_POST["user"];
$query = mysql_query("SELECT * FROM accounts WHERE Username='$username'");
if(mysql_num_rows($query) != 0)
{
echo "Username already exists";
}
else
{
}