Thursday, 12 September 2013

trim not working for ajax send? $_POST

trim not working for ajax send? $_POST

$name = trim(&$_POST['name']);
why trim this way would not work? I was following a tutorial, it put &
sign before $_POST['name'] which I was not sure what is that for.. I got
an error when it is $name = $_POST['name'];
this is the following lines of code
if($name && $email && $password && $cpassword){
mysql_connect("127.0.0.1","root","") or die("Fail to connect to
database");
mysql_select_db("reglog");
mysql_query("INSERT INTO users(username,email,password)
VALUES('$name','$email','$cpassword')");
echo 1;
}else{
echo "not allowed";
}
by using $name = trim(&$_POST['name']);
I dont get the 1 value return to my ajax data

No comments:

Post a Comment