I’m making a form and when a user hits submit, i want it to hide the form and show a section that says “thank you, blah blah”
I’m using PHP/PEAR Mail Factory:
$mailObj =& Mail::factory('mail');
$bool = $mailObj->send($recipient, $headers, $body);
if($bool)
echo "Thank you for your submission.";
else
echo "There was a problem processing your request.";
$body = ""; // clear the body
I think you’re confusing client-side and server-side operations. If you simply want to change the appearance of your form page upon submission, you can indeed handle that entirely on the client side.
If you want to stay on that form page, but change its appearance based on information returned from your server (as in your sample php code), then you’ll need to do an asynchronous form submission. You can use jQuery’s
$.ajax()function or its relatives, then change your page in the callback function based on the success/failure information you return from your server-side script.Simple example: