Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > PHP

Reply
 
LinkBack Thread Tools
Old 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 Posie is on a distinguished road
[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!
Posie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old January 24th, 2008, 01:40 AM   #2
Elite Veteran
 

Join Date: Jul 2007
Location: Webforumz 24/7
Age: 17
Posts: 3,799
Blog Entries: 9
Thanks: 2
Thanked 3 Times in 3 Posts
Rep Altering Power: 0 alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all
Re: PHP contact form redirect to same form

Post your email sending code, we can just add a simple header.
__________________
Web Design and Development Blog

Alex Perry
Technical Administrator.
alexgeek is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old 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 Posie is on a distinguished road
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!
Posie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old January 24th, 2008, 01:51 AM   #4
Elite Veteran
 

Join Date: Jul 2007
Location: Webforumz 24/7
Age: 17
Posts: 3,799
Blog Entries: 9
Thanks: 2
Thanked 3 Times in 3 Posts
Rep Altering Power: 0 alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all
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!';

__________________
Web Design and Development Blog

Alex Perry
Technical Administrator.
alexgeek is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old 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 Posie is on a distinguished road
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!
Posie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old January 24th, 2008, 02:19 AM   #6
Elite Veteran
 

Join Date: Jul 2007
Location: Webforumz 24/7
Age: 17
Posts: 3,799
Blog Entries: 9
Thanks: 2
Thanked 3 Times in 3 Posts
Rep Altering Power: 0 alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all
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:
HTML Code:
<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
__________________
Web Design and Development Blog

Alex Perry
Technical Administrator.
alexgeek is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old 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 Posie is on a distinguished road
Re: PHP contact form redirect to same form

Ah, you are a lifesaver!

Now on to validation, I promise.

Thanks again. I appreciate you!
Posie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old January 24th, 2008, 02:50 AM   #8
Elite Veteran
 

Join Date: Jul 2007
Location: Webforumz 24/7
Age: 17
Posts: 3,799
Blog Entries: 9
Thanks: 2
Thanked 3 Times in 3 Posts
Rep Altering Power: 0 alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all
Re: PHP contact form redirect to same form

You're welcome, Good Luck validating. It's mainly just a few alt attributes missing.
__________________
Web Design and Development Blog

Alex Perry
Technical Administrator.
alexgeek is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old 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 Posie is on a distinguished road
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.)
Posie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old January 24th, 2008, 02:57 AM   #10
Elite Veteran
 

Join Date: Jul 2007
Location: Webforumz 24/7
Age: 17
Posts: 3,799
Blog Entries: 9
Thanks: 2
Thanked 3 Times in 3 Posts
Rep Altering Power: 0 alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all
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.
__________________
Web Design and Development Blog

Alex Perry
Technical Administrator.
alexgeek is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old 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 Posie is on a distinguished road
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");
?>
Posie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old 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 Posie is on a distinguished road
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!
Posie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old January 28th, 2008, 12:44 AM   #13
Highly Reputable Member
 

Join Date: Apr 2007
Location: Willich, Germany
Age: 22
Posts: 592
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 c010depunkk is a jewel in the rough c010depunkk is a jewel in the rough c010depunkk is a jewel in the rough c010depunkk is a jewel in the rough
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....
c010depunkk is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old January 28th, 2008, 10:37 AM   #14
Highly Reputable Member
 
masonbarge's Avatar
 

Join Date: Jan 2006
Location: Atlanta GA
Posts: 649
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 masonbarge will become famous soon enough
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>
masonbarge is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old 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 Posie is on a distinguished road
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!
Posie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] PHP contact form problem fl0w PHP 12 January 31st, 2008 01:56 PM
[SOLVED] PHP Contact Form Stuart PHP 8 December 4th, 2007 01:42 PM
[SOLVED] Contact Form Help danny322 PHP 3 November 7th, 2007 12:05 PM
[SOLVED] PHP Contact Form Stuart PHP 9 October 19th, 2007 08:48 PM
Redirect for an ASP Contact Form Sporky Classic ASP 9 January 26th, 2007 09:00 AM


Search Engine Optimization by vBSEO 3.2.0 RC8