This is a discussion on "[SOLVED] PHP contact form redirect to same form" within the PHP Forum section. This forum, and the thread "[SOLVED] PHP contact form redirect to same form are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
[SOLVED] PHP contact form redirect to same form
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
[SOLVED] PHP contact form redirect to same form
Sorry if that title was confusing... I wasn't sure how to get it all in!
I have a contact form on my website at the page http://www.centraloregonweddingflowe.../contacts.html Currently, my php email works fine and sends an email to me, but when it is submitted, a new blank page is brought up. Confusing for the sender! I would love to have the same contacts.html page reload, BUT with the words "Thank You" in the text box area where the user types their message. Is this possible? Or maybe I should ask, advisable? Thanks in advance for your help! |
|
|
|
||||
|
Re: PHP contact form redirect to same form
Post your email sending code, we can just add a simple header.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
|||
|
Re: PHP contact form redirect to same form
Ok, but I apologize that it's not validating the fields yet... I like to get it working then start fiddling with it, so I can see where I went wrong.
So with that disclaimer, here it is:
|
|
||||
|
Re: PHP contact form redirect to same form
Okay add under the last line:
Then put this where you want the thank you to appear:
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
|||
|
Re: PHP contact form redirect to same form
Thank you! I have a few assumptions and questions about this:
1. I need to put that new last line inside the php script (before ?>) right? 2. Can I make a copy of my current contacts.html page and save it as a .php page just used for this purpose, keeping my html page also to avoid updating all my links? 3. Does the isset/echo bit go in the contacts.php page? If I want it to show up in the message textbox, do I need to place it somewhere in this area?
|
|
||||
|
Re: PHP contact form redirect to same form
1. Yes.
2. Yes. 3. Yes. You can place it wherever you like. E.G. <h1>Contact Page</h1> To make it appear in the <h1> You'd use:
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
|||
|
Re: PHP contact form redirect to same form
Ah, you are a lifesaver!
Now on to validation, I promise. Thanks again. I appreciate you! |
|
||||
|
Re: PHP contact form redirect to same form
You're welcome, Good Luck validating. It's mainly just a few alt attributes missing.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
|||
|
Re: PHP contact form redirect to same form
Well, I still appreciate you, but I'm getting another error.
When I hit submit, my email is still sent, but I get a new page with the following message: The document name you requested (/index.php) could not be found on this server. However, we found documents with names similar to the one you requested.Available documents: Any ideas? I am running php files in different folders for this website, so I probably have an index.php file (or two) around. Is there a reason it's looking for one here? (By the way, I took out the "?thankyou" and reloaded the page to see if that would help. I was getting the same message before.) |
|
||||
|
Re: PHP contact form redirect to same form
You have this exact line right?
Why the hell would it ask for index.php? This is baffling me. I'll have another look later.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
|||
|
Re: PHP contact form redirect to same form
Yes, here is my whole file:
|
|
|||
|
Re: PHP contact form redirect to same form
I'm wondering if there is a more straightforward way to solve my problem.
What about redirecting the page back to the original "contact.html" page, with a pop-up box that says "Thank you" and a button to close it. Would this be easier? Or is there a very simple answer that I should be looking at? I really just want the user to know that their message was sent and allow them to continue browsing. Thanks in advance! |
|
||||
|
Re: PHP contact form redirect to same form
If you check the stickies, you'll find a basic tutorial on sending an email using PHP.
here: PHP mail() --> Making a Form / Validating Input / Sending an email See if that helps....
Last Blog Entry: 10 Reasons Why My Laptop Is Better Than Your Girlfriend (Dec 15th, 2007)
|
|
||||
|
Re: PHP contact form redirect to same form
I'll try to give a few suggestions, easiest to hardest.
First, try inserting "$_GET" for "$_POST" in the little target page script. The whole thing might work. If not, are you using some kind of mod_rewrite? Probably not, but that can mess up a URL. If not, check to make sure your server isn't forcing you into "safe mode". Normally this would give you a more specific error message but it could easily mess up a redirect. One idea, of course, is to create a page named "index.php" and see what happens. The error message you are getting is a "status 300" http header, which means that your page is requesting multiple addresses -- one (apparently) automatically to the url "www.centraloregonweddingflowers.com/", which then like any empty directory request searches for an "index.php" page, and a second one specified by "header()". You might try commenting out the "header()" line, submit, and copy down the URL of the blank white page that you were getting before. An HTTP problem is beyond the scope of this forum. though. You might want to ask your server host about this problem. Redirecting through use of the PHP header() function is too valuable not to work right. In the meantime, do something that works. Like, after the mail has been sent, echo (or just close php and use html) a nice blank page with the words "Your mail has been sent. Thank You!", a couple of breaks, and a link or two, like
|
|
|||
|
Re: PHP contact form redirect to same form
Well, I finally got a simple solution to work.
After my original php email script, I just added the code for the html page I wanted to direct it to (since I only had one anyway) with a link back to the contact page. Sometimes simplest is best, even if complicated is more exciting! Thanks so much for all your help everyone! |
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [SOLVED] PHP contact form problem | fl0w | PHP Forum | 12 | Jan 31st, 2008 17:56 |
| [SOLVED] PHP Contact Form | Stuart | PHP Forum | 8 | Dec 4th, 2007 17:42 |
| [SOLVED] Contact Form Help | danny322 | PHP Forum | 3 | Nov 7th, 2007 16:05 |
| [SOLVED] PHP Contact Form | Stuart | PHP Forum | 9 | Oct 20th, 2007 00:48 |
| Redirect for an ASP Contact Form | Sporky | Classic ASP | 9 | Jan 26th, 2007 13:00 |