Grow your CSS skills. Land your dream job.

How to load an Error page on the same page as the Submission

  • # July 15, 2013 at 1:03 pm

    Hello,

    I am new to the PHP world, so please forgive me if anything in this post is “newbie”.

    I have a PHP submission form, and I have it redirecting to an error page if the e-mail is incorrect, and thank you page for when everything is good.

    I can’t seem to figure out how (or if it’s even possible) to make it so the Error and Thank you pages show up on the page as that the form is on. I don’t want it to redirect to a new page. I want it to show up under the “Submit” button.

    I can post the php code I have now if needed.
    Any help is greatly appreciated.

    Thanks!

    Mike W.

    # July 15, 2013 at 1:48 pm

    You need to submit the form via AJAX (jQuery has a good [AJAX library](http://api.jquery.com/category/ajax/)). On the server side, your php script needs to `print` the response (not redirect), and then you can use javascript to display the response as desired.

    # July 16, 2013 at 12:15 pm

    Thank you for the response. So I’ve never used AJAX, so I’m sorry if this is stupid, but does that mean I need to convert my PHP code to AJAX? or just add an AJAX form in addition.

    Thank you so much.

    # July 16, 2013 at 3:27 pm

    No, [ajax](http://en.wikipedia.org/wiki/Ajax_%28programming%29) is a technique that uses javascript to submit an http request to a server, and receive/process the response, without refreshing the page being viewed in the browser. That’s why I suggested looking at jQuery.

    # July 16, 2013 at 7:05 pm

    Awesome! Thank you so much, I will take a look into that.

    Much appreciated!

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".