hi friends
I have design a signup page but i cant insert data to database I used ajax mechanism with php script!! pls give me solution i cant find error in my code
ajaxresponseText returns "signup success" but no data inserts database
<?php
if(isset($_POST["u"])){
include_once("db_conx.php");
$u = preg_replace('#[^a-z0-9]#i','',$_POST['u']);
$e = mysqli_real_escape_string($db_conx,$_POST['e']);
$p = $_POST['p'];
$g = preg_replace('#[^a-z]#','',$_POST['g']);
$c = preg_replace('#[^a-z}]#','',$_POST['c']);
$ip = preg_replace('#[^1-9.]#','', getenv('REMOTE ADDR'));
$sql = "SELECT id FROM users WHERE username='$u'LIMIT 1";
if ($u_check = mysqli_query($db_conx,$sql))
{
mysqli_num_rows($u_check);
}
$sql = "SELECT id FROM users WHERE email='$e' LIMIT 1";
if($e_check = mysqli_query($db_conx,$sql))
{
mysqli_num_rows($e_check);
}
if($u== ""|| $e == "" || $p == "" || $g == "" || $c == "")
{
echo "The form submission is missing values.";
exit();
}
else if ($u_check > 0)
{
echo " The username you entered is already taken";
exit();
}
else if ($e_check > 0)
{
echo "Email Address is already in use";
exit();
}
else if(strlen($u)< 3 || strlen($u) > 16)
{
echo " username must be between 3 and 16 characters";
exit();
}
else if(is_numeric($u[0]))
{
echo 'UserName cannot begin with a number';
exit();
}
else
{
crypt($p);
include_once("randStrGen.php");
$p_hash = randStrGen(20)."$p".randStrGen(20);
echo"$u $e $p_hash $g $c $ip";
$sql = "INSERT INTO users(username,email,password,gender,country,ip,signup,lastlogin,notescheck) VALUES('$u','$e','$p_hash','$g','$c','$ip,now(),now(),now())";
$query = mysqli_query($db_conx,$sql);
$uid = mysqli_insert_id($db_conx);
if(!file_exists("user/$u")){
mkdir("user/$u",0755);
}
$to = "$e";
$from = "noreply@maxdudes.com";
$subject = 'maxdudes Account Activation';
$message = '<!DOCTYPE html><html><head><meta charset="UTF-8"><title>yoursitename Message</title></head><body style="margin:0px; font-family:Tahoma, Geneva, sans-serif;"><div style="padding:10px; background:#333; font-size:24px; color:#CCC;"><a href="http://www.yoursitename.com"><img src="http://www.yoursitename.com/images/logo.png" width="36" height="30" alt="yoursitename" style="border:none; float:left;"></a>yoursitename Account Activation</div><div style="padding:24px; font-size:17px;">Hello '.$u.',<br /><br />Click the link below to activate your account when ready:<br /><br /><a href="http://www.yoursitename.com/activation.php?id='.$uid.'&u='.$u.'&e='.$e.'&p='.$p_hash.'">Click here to activate your account now</a><br /><br />Login after successful activation using your:<br />* E-mail Address: <b>'.$e.'</b></div></body></html>';
$headers = "From: $from\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
echo "signup_success";
exit();
}
exit();
}
?>