The Lodge is members-only design/dev videos and Office Hours.

Next Office Hours Session: "Programming Fundamentals" Dec 02 - 2:00 PM Eastern

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

  • # July 15, 2013 at 1:03 pm


    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.


    Mike W.

    # July 15, 2013 at 1:48 pm

    This reply has been reported for inappropriate content.

    You need to submit the form via AJAX (jQuery has a good AJAX library). 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

    This reply has been reported for inappropriate content.

    No, ajax 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.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed