PHP anyone?
- Started
- Last post
- 11 Responses
- planet01
This is my first attempt at creating a feedback form in PHP.
The form is functional, the email gets sent. Once the form is submitted, the mailer.php spits out some generic thank you copy on the screen. I would rather it redirected to an html page, but nothing I do seems to work.
Here is the code that generates the plain text right now...
(echo "thank you";)
Any help would be great. Thanks!
- acescence0
header ( "Location: http://www.site.com/" );
- planet010
I get this error when I try that...
Warning: Cannot modify header information - headers already sent by (output started at /home/jimkraus/public_html/maile... in /home/jimkraus/public_html/maile... on line 13
- acescence0
you can't modify header if something has already been printed to the browser. you have some code before the header line that's echoing or printing to the browser window, you need to remove it
- van_rijn0
can just use a if !$_POST statement on the same page, then an else
just have the page name in the form tag
as for making forms, i use the PHPMailer
http://phpmailer.sourceforge.net…
- planet010
hmmm... here's the code - not sure what the issue is
if(isset($_POST['submit'])) {
$to =
$subject = "Feedback -
Frauds, Innaccuracies,
Falsehoods, and Outright
Lies";
$name_field =
$_POST['name'];
$email_field =
$_POST['email'];
$message =
$_POST['message'];$body = "From:
$name_field\n E-Mail:
$email_field\n Message:\n
$message";header ( "Location:
http://www.jimkraus.com/thankyou…
);
mail($to, $subject, $body);} else {
echo "Error - Please re-submit
form";}
- van_rijn0
no need for a header
- planet010
i'm obviously in over my head on this one...
what's the right way to set the link then?
I need to replace
(echo "thank you";)
with what?
- acescence0
ok, you're inserting the header before you send the mail, that won't work. the header redirect comes after the mail() part
second, the header is failing because there is whitespace somewhere before your code starts, which means php has already sent a header to the browser
make sure the very first line and very first character of your script is the < ? php directive
- van_rijn0
hard to explain.
check yer mail
- planet010
Thanks for the help - it works!