$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
here is my js
$("#send").click(function(){
var all = $("form").serialize();
if(validateName() & validateEmail() & validatePass1() & validatePass2() == true){
$.ajax({
type: "post",
url: "insert.php",
data: all,
success: function(data){
if(data==1){
alert("success, you have registered");
}else{
alert('Validate your form with correct informations to proceed!');
}
}
});
}
});