|
|
 |
January 24th, 2008, 01:30 AM
|
#1
|
|
New Member
Join Date: Nov 2007
Location: Oregon
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0
|
[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!
|
|
|
January 24th, 2008, 01:40 AM
|
#2
|
|
Elite Veteran
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 17
Posts: 3,799
Thanks: 2
Thanked 3 Times in 3 Posts
|
Re: PHP contact form redirect to same form
Post your email sending code, we can just add a simple header.
|
|
|
January 24th, 2008, 01:46 AM
|
#3
|
|
New Member
Join Date: Nov 2007
Location: Oregon
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0
|
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:
Code:
<?
$destination="info@centraloregonweddingflowers.com";
$name=$_POST['name1'];
$email=$_POST['email'];
$from = 'info@centraloregonweddingflowers.com';
$cell=$_POST['cell'];
$phone=$_POST['number'];
$mes=$_POST['message1'];
$subject="Message from $name" ;
$header="From: $from\n";
$mes="Name: $name\n
Email: $email\n
Phone: $phone\n
Cell: $cell\n
Comments: $mes\n";
mail($destination,$subject,$mes,$header); ?>
Thanks for your help!
|
|
|
January 24th, 2008, 01:51 AM
|
#4
|
|
Elite Veteran
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 17
Posts: 3,799
Thanks: 2
Thanked 3 Times in 3 Posts
|
Re: PHP contact form redirect to same form
Okay add under the last line:
Code:
header("Location: http://www.centraloregonweddingflowers.com/contacts.php?thankyou");
Notice that your contact form page has to be renamed to . php.
Then
put this where you want the thank you to appear:
Code:
if(isset($_POST['thankyou'])) { echo 'Thank you!'; }
|
|
|
January 24th, 2008, 02:10 AM
|
#5
|
|
New Member
Join Date: Nov 2007
Location: Oregon
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0
|
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?
Code:
<td valign="top"><span style="color:#999999">Message</span></td>
<td><textarea class="mess" name="message1"></textarea></td>
</tr>
Thanks so much for your help and patience!
|
|
|
January 24th, 2008, 02:19 AM
|
#6
|
|
Elite Veteran
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 17
Posts: 3,799
Thanks: 2
Thanked 3 Times in 3 Posts
|
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:
<h1>Contact Page <?php
if(isset($_POST['thankyou'])) {
echo ', Thank you!';
} ?>
This would show: <h1>Contact Page</h1> if the email hadn't been sent yet. And <h1>Contact Page, Thank you!</h1> if it had 
|
|
|
January 24th, 2008, 02:23 AM
|
#7
|
|
New Member
Join Date: Nov 2007
Location: Oregon
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0
|
Re: PHP contact form redirect to same form
Ah, you are a lifesaver!
Now on to validation, I promise.
Thanks again. I appreciate you!
|
|
|
January 24th, 2008, 02:50 AM
|
#8
|
|
Elite Veteran
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 17
Posts: 3,799
Thanks: 2
Thanked 3 Times in 3 Posts
|
Re: PHP contact form redirect to same form
You're welcome, Good Luck validating. It's mainly just a few alt attributes missing.
|
|
|
January 24th, 2008, 02:50 AM
|
#9
|
|
New Member
Join Date: Nov 2007
Location: Oregon
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0
|
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.)
|
|
|
January 24th, 2008, 02:57 AM
|
#10
|
|
Elite Veteran
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 17
Posts: 3,799
Thanks: 2
Thanked 3 Times in 3 Posts
|
Re: PHP contact form redirect to same form
You have this exact line right?
Code:
header("Location: http://www.centraloregonweddingflowers.com/contacts.php?thankyou");
That should definitely work, I just checked and it is a real page..
Why the hell would it ask for index. php? This is baffling me.
I'll have another look later.
|
|
|
January 24th, 2008, 03:09 AM
|
#11
|
|
New Member
Join Date: Nov 2007
Location: Oregon
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0
|
Re: PHP contact form redirect to same form
Yes, here is my whole file:
Code:
<?
$destination="info@centraloregonweddingflowers.com";
$name=$_POST['name1'];
$email=$_POST['email'];
$from = 'info@centraloregonweddingflowers.com';
$cell=$_POST['cell'];
$phone=$_POST['number'];
$mes=$_POST['message1'];
$subject="Message from $name" ;
$header="From: $from\n";
$mes="Name: $name\n
Email: $email\n
Phone: $phone\n
Cell: $cell\n
Comments: $mes\n";
mail($destination,$subject,$mes,$header);
header("Location: http://www.centraloregonweddingflowers.com/contacts.php?thankyou");
?>
|
|
|
January 27th, 2008, 10:04 PM
|
#12
|
|
New Member
Join Date: Nov 2007
Location: Oregon
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0
|
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!
|
|
|
January 28th, 2008, 12:44 AM
|
#13
|
|
Highly Reputable Member
Join Date: Apr 2007
Location: Willich, Germany
Age: 22
Posts: 592
Thanks: 0
Thanked 0 Times in 0 Posts
|
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: http://www.webforumz.com/php-forum/6...validating.htm
See if that helps....
|
|
|
January 28th, 2008, 10:37 AM
|
#14
|
|
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 649
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0
|
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
Code:
<a href="./whereveryourwantthemtogo.php">Click to continue . . .</a>
|
|
|
January 29th, 2008, 04:28 PM
|
#15
|
|
New Member
Join Date: Nov 2007
Location: Oregon
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0
|
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!
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|