I have a password reset PHP form page that has another PHP file in action attribute of form tag. the latter (say process.php
) processes the formers(say reset.php
) form data to reset the password in the database now in between these two I have used a js file for client-side form validation and sending $.post request
in the data attribute of $.post request i inserted the $data = $("#passwordresetform :input").serializeArray();
until this point, every thing works fine when I see form data in developer tool for process.php page it shows the data as required but I have received the data in process.php using
mysql_real_escape_string(trim($_POST['email']));
and stored all values in the associative array as
$data = array (
'name' => $username,
'email' => $email,
'password' => $pass,
);
to return the data I have used
echo json_encode($data);
but it not returning data back e.g when I seeing preview section of developer tool it shows false for every key in returned data object i.e data
how do I solve this problem? thanks in advance.
I think the problem is really with my database connection as after I removed mysql_real_escape_string(trim(
it worked fine so is there any other way to sanitize $_POST
data?
but had it been a database connection problem then how come the same page retrieves data from database?