Im fairly new to php and am currently trying to make a user area on my site and i want to make a signup script but the one i’ve got isn’t working right.
reg_info.php
[code]<?
include(“config.php”);
$check[0] = mysql_query(“SELECT email FROM Account WHERE email = ‘$email’”);
$check[1] = mysql_query(“SELECT username FROM Account WHERE username = ‘$username’”);
mysql_select_db($db, $con);
function user_valid($user)
{
if(!isset($user))
{
$status = 0;
$msg = $msg . "You have not inserted a username
";
}
elseif(6 > strlen($user))
{
$status = 0;
$msg = $msg . "Your username must be longer than 5 characters
";
}
elseif(strlen($user) > 30)
{
$status = 0;
$msg = $msg . "Your username must be shorter or equal to 30 characters long
";
}
else
{
}
}
function pass_valid($pass, $pass2)
{
if(!isset($pass))
{
$status = 0;
$msg = $msg . "You need to enter a password
";
}
elseif($pass != $pass2)
{
$status = 0;
$msg = $msg . "Both passwords need to match
";
}
elseif( 6 > strlen($pass))
{
$status = 0;
$msg = $msg . "Password must be longer than 5 characters
";
}
elseif(strlen($pass) > 32)
{
$status = 0;
$msg = $msg . "Password must be shorter or equal to 32 characters
";
}
else
{
}
}
function email_valid($mail)
{
if(!isset($mail))
{
$status = 0;
$msg = $msg . "Email must be entered
";
}
elseif(6 > strlen($mail))
{
$status = 0;
$msg = $msg . "Email must be longer than 5 Characters long
";
}
elseif(strlen($mail) > 30)
{
$status = 0;
$msg = $msg . "Email must be shorter or equal to 30 characters long
";
}
else
{
}
}
function misc_valid($uname, $e_mail)
{
$query = mysql_query(“SELECT COUNT(id) FROM Account WHERE username = ‘$uname’”) or die(mysql_error());
$query2 = mysql_query(“SELECT COUNT(id) FROM Account WHERE email = ‘$e_mail’”) or die(mysql_error());
list($count) = mysql_fetch_array($query);
list($count2) = mysql_fetch_array($query2);
if($count > 0)
{
$status = 0;
$msg = $msg . "Username is already taken
";
}
elseif($count2 > 0)
{
$status = 0;
$msg = $msg . "Email is already taken
";
}
else
{
}
}
if(isset($reg) && $reg == “reg258741”)
{
$status = 1;
$msg = “”;
user_valid($username);
pass_valid($password, $password2);
email_valid($email);
misc_valid($username, $email);
$md5password = MD5($password);
$newusername = addslashes($username);
$newemail = addslashes($email);
if($status == 0)
{
echo “<color = ‘red’>” . $msg . "
Go Back and try again ";
}
else
{
mysql_query(“INSERT INTO Account (username, password, email) VALUES ($newusername, $md5password, $newemail)”);
echo "<color = ‘green’> You have successfully registered
";
echo "An email has been sent to the email address provided you will need to activate your account before logging in
";
echo “Please login here”;
}
}
else
{
echo “Please use the registration form”;
}
?>[/code]
config.php
[code]<?
// Database Variables //
$con = mysql_connect(“localhost”, “”, “”);
$db = “”;
// Form Variables //
$username = $_POST[‘username’];
$password = $_POST[‘password’];
$password2 = $_POST[‘password2’];
$email = $_POST[‘email’];
$terms = $_POST[‘terms’];
$reg = $_POST[‘reg258741’];
?>[/code]
The problem im getting is that even if you fill form wrong it says account made, when the account hasn’t been made, any help please?