| Author |
small problem with PHP form
|
|
|
| http://www.saysocreative.com/clients/aim/contact.html
Fill the form out and click send. The form process and actually delivers to me
email, however i get and error message instead of being redirected....i use
this form script in other forms and donot get this problem....
The error is:
Warning: Cannot modify header information - headers already sent by (output
started at /home/syoungin/public_html/saysocreative/clients/aim/mailer.php:2)
in /home/syoungin/public_html/saysocreative/clients/aim/mailer.php on line 20
The form script is
<?php
if(isset($_POST['submit'])) {
$to = "feedback@saysocreative.com";
$subject = $_POST['Subject'];
$name_field = $_POST['Name'];
$email_field = $_POST['E-mail'];
$phone_field = $_POST['phone'];
$work_field = $_POST['Work'];
$subject_field = $_POST['Subject'];
$message = $_POST['Message'];
$body = "From: $name_field
\nE-Mail: $email_field
\nContact #: $phone_field
\nWant a Job?: $work_field
\nSubject: $subject_field
\nMessage:\n$message";
if(mail($to, $subject, $body)){
header('Location: http://www.saysocreative.com');
exit;
}else{
echo "Failed to send message!";
}
}
?>
| |
| Ryan Butler 2006-02-28, 6:22 pm |
| No PHP genius by any means, but this is what I've used in the past and it
surpasses the header warning fine:
<meta http-equiv="refresh" content="1;url=enter_url_here">
<?
}
}
?>
Try putting the above at the very end of your PHP script and see if it works
for you.
Ryan
"wadup" <webforumsuser@macromedia.com> wrote in message
news:du2iho$saq$1@forums.macromedia.com...
> http://www.saysocreative.com/clients/aim/contact.html
>
> Fill the form out and click send. The form process and actually delivers
> to me
> email, however i get and error message instead of being redirected....i
> use
> this form script in other forms and donot get this problem....
>
> The error is:
>
> Warning: Cannot modify header information - headers already sent by
> (output
> started at
> /home/syoungin/public_html/saysocreative/clients/aim/mailer.php:2)
> in /home/syoungin/public_html/saysocreative/clients/aim/mailer.php on line
> 20
>
> The form script is
>
>
>
> <?php
> if(isset($_POST['submit'])) {
> $to = "feedback@saysocreative.com";
> $subject = $_POST['Subject'];
> $name_field = $_POST['Name'];
> $email_field = $_POST['E-mail'];
> $phone_field = $_POST['phone'];
> $work_field = $_POST['Work'];
> $subject_field = $_POST['Subject'];
> $message = $_POST['Message'];
> $body = "From: $name_field
> \nE-Mail: $email_field
> \nContact #: $phone_field
> \nWant a Job?: $work_field
> \nSubject: $subject_field
> \nMessage:\n$message";
>
> if(mail($to, $subject, $body)){
> header('Location: http://www.saysocreative.com');
> exit;
> }else{
> echo "Failed to send message!";
> }
> }
>
> ?>
>
| |
| Michael Fesser 2006-02-28, 6:22 pm |
| ..oO(Ryan Butler)
>No PHP genius by any means, but this is what I've used in the past and it
>surpasses the header warning fine:
>
><meta http-equiv="refresh" content="1;url=enter_url_here">
><?
>}
>}
>?>
Please don't suggest such things if you don't know what it does and the
consequences. The above is dangerous, unreliable and will definitely not
solve the OP's problem.
Micha
| |
| David Powers 2006-02-28, 10:14 pm |
| wadup wrote:
> The error is:
>
> Warning: Cannot modify header information - headers already sent
"Headers already sent" is a typical beginner's mistake, which also
catches out the more experienced from time to time. What it means is
that some output has already been sent to the browser before your call
to header(), which is being used to redirect the page.
You may not think that any output has been sent, but *anything* sent to
the browser before header() will trigger this problem. The most common
cause is white space before your opening PHP tag. Another frequent cause
of the problem is an include file that has white space after the closing
PHP tag.
Open your file (as well as any include files) in Code view. Make sure
the opening PHP tag is right at the top of line one. Also make sure that
there are no blank lines or blank spaces after the closing PHP tag. Then
your problem should vanish into thin air.
--
David Powers
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "Foundation PHP 5 for Flash" (friends of ED)
http://foundationphp.com/
| |
| David Powers 2006-02-28, 10:15 pm |
| Gary White wrote:
> Another cause could be the script generating a warning or error message
> before it gets to the header call.
Good point.
--
David Powers
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "Foundation PHP 5 for Flash" (friends of ED)
http://foundationphp.com/
| |
| Gary White 2006-02-28, 10:15 pm |
| On Tue, 28 Feb 2006 23:13:33 +0000, David Powers <david@example.com>
wrote:
>You may not think that any output has been sent, but *anything* sent to
>the browser before header() will trigger this problem. The most common
>cause is white space before your opening PHP tag. Another frequent cause
>of the problem is an include file that has white space after the closing
>PHP tag.
Another cause could be the script generating a warning or error message
before it gets to the header call.
Gary
| |
| wadup 2006-02-28, 10:15 pm |
| Thansk for the help guys, ill lok and see if i can fix it in a min and let you
al knwo if it works.......thanks for the help though...
ps-Why are apple power cords $70? I Just had to buy a replacement for my
powerbook, i guess i wouldnt be eating this month!
|
|
|
|
| Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |