Welcome to WebmasterWorld Guest from 23.22.182.29

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Simple Contact Form Redirect - What Am I Missing?

The contact form works but unable to resolve to thank you page

     
4:49 pm on Jun 28, 2008 (gmt 0)

New User

10+ Year Member

joined:Oct 26, 2005
posts: 16
votes: 0


Here is my problem.
I created a simple contact form and right now when I hit send it:
Sends the email, message and information correctly, however it does not resolve to the thank you page.

I know I am missing something but not sure what so I have included a bit of info below: .
From the form: The submit action is below:
<td><input type="submit" name="submit" value="Submit" /></td>

PHP Form Processing File:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?php
// Pick up the form data and assign it to variables
$name = $_POST['name'];
$email = $_POST['email'];
$comments = $_POST['comments'];

// Build the email (replace the address in the $to section with your own)
$to = '#*$!#*$!@yahoo.com';
$subject = "New Message: $topic";
$message = "$name said: $comments";
$headers = "From: $email";

// Send the mail using PHPs mail() function
mail($to, $subject, $message, $headers);

// Redirect
header("Location: [#*$!#*$!x.com...]

?>

Error Message:
Line 19 is the header line:
Warning: Cannot modify header information - headers already sent by (output started at /home/supersk/public_html/#*$!#*$!.com/contact_us/process_form.php:3) in /home/supersk/public_html/#*$!#*$!.com/contact_us/process_form.php on line 19

I feel so stupid and know that it will take seconds for someone to spot my error, back after hours of reading, testing and making zero headway. I thought I would ask for help. (Thanks in advance)
Russ

5:32 pm on June 28, 2008 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member henry0 is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Apr 19, 2003
posts: 4388
votes: 2


From the manual
Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP

The Manual [php.net] is your best friend

Another solution: Edit your php.ini and allow for output buffering (OB), don't forget to restart Apache.
then you may send any header from where ever :)

6:24 pm on June 28, 2008 (gmt 0)

New User

10+ Year Member

joined:Oct 26, 2005
posts: 16
votes: 0


I will check out the manual the rest just few right over my head. I am a true newbie to php. I was hoping soe one would answer like hey you need to place $ here or ; there.
6:34 pm on June 28, 2008 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member henry0 is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Apr 19, 2003
posts: 4388
votes: 2


it is all explained in the provided link (manual)

and regarding php.ini you may ask your ISP to help you

Best way to learn php is to ask, try, read and look for the how to, not for a canned solution:)

11:53 am on June 29, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member dreamcatcher is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 30, 2003
posts:3719
votes: 0


You need to remove this block of code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

dc