Well its getting there, couldnt figure out why it was not displaying therefore I tried a few things and replacing "==" for "=" worked for some reason.
So im almost there and after adding more email verification (to defend against bots) ill be done.
Please tell me why this script shows please fill in all fields even when all fields are filled in. Obviously one of the variables is coming through as empty but I dont know why.
Last question is, what is the name for the verification method that works against bots i.e. you have to enter characters shown in a picture into a form.
Thanks
<?php
session_start();
require "connect.php";
$email = $_POST['email'];
$alias = $_POST['alias'];
$password = $_POST['password'];
$password2 = $_POST['password2'];
if ($password == $password2)
{
$email = mysql_query("SELECT * FROM accounts WHERE (email='$email')")
or die("MySQL Error: ".mysql_error());
$alias = mysql_query("SELECT * FROM accounts WHERE (alias='$alias')")
or die("MySQL Error: ".mysql_error());
if((mysql_num_rows($email) > 0) && (mysql_num_rows($alias) > 0))
{
$error4 = "Email name taken.";
$_SESSION["error4"] = $error4;
$error2 = "Alias Name Taken.";
$_SESSION["error2"] = $error2;
header("Location: index.php");
}
else if(mysql_num_rows($alias) > 0)
{
$error2 = "Alias Name Taken.";
$_SESSION["error2"] = $error2;
header("Location: index.php");
}
else if((mysql_num_rows($email) > 0))
{
$error4 = "Email taken.";
$_SESSION["error4"] = $error4;
header("Location: index.php");
}
else if((isset($email)) || (isset($alias)) || (isset($password)) || (isset($password2)))
{
$error6 = "Use all fields.";
$_SESSION["error6"] = $error6;
header("Location: index.php");
}
else
{
$email = $_POST['email'];
$alias = $_POST['alias'];
$passwordHash = sha1($password);
$alias = mysql_query("INSERT INTO accounts VALUES('".$email."','".$alias."','".$passwordHash."')")
or die("MySQL Error: ".mysql_error());
$error3 = "Registered.";
$_SESSION["error3"] = $error3;
header("Location: index.php");
}
}
else
{
$error = "Password does not match.";
$_SESSION["error"] = $error;
header("Location: index.php");
}
?>