PHP Form Help
Moderator: General Moderators
PHP Form Help
Hi im new here and ive got a question I need answering.
Ive recently created a php form but when I click submit I never recieve an email. After viewing other sites and tutorials I have the following code.
<?
mail( "bookings@gfunk-online.co.uk", "Feedback Form Results",
$message, "From: $email", "-yourname@yourdomain.com" );
header( "Location: http://www.gfunk-online.co.uk/confirmation.html" );
?>
I found out I have to put the code 'ini_set ("sendmail_from", "bookings@gfunk-online.co.uk")' in somewhere but I dont know where. If I put it before the code above I get an error message;
ini_set ("sendmail_from", "bookings@gfunk-online.co.uk")
Warning: Cannot modify header information - headers already sent by (output started at e:\domains\g\gfunk-online.co.uk\user\htdocs\sendmail.php:3) in e:\domains\g\gfunk-online.co.uk\user\htdocs\sendmail.php on line 6
Can anyone help me please?
Thanks
Ive recently created a php form but when I click submit I never recieve an email. After viewing other sites and tutorials I have the following code.
<?
mail( "bookings@gfunk-online.co.uk", "Feedback Form Results",
$message, "From: $email", "-yourname@yourdomain.com" );
header( "Location: http://www.gfunk-online.co.uk/confirmation.html" );
?>
I found out I have to put the code 'ini_set ("sendmail_from", "bookings@gfunk-online.co.uk")' in somewhere but I dont know where. If I put it before the code above I get an error message;
ini_set ("sendmail_from", "bookings@gfunk-online.co.uk")
Warning: Cannot modify header information - headers already sent by (output started at e:\domains\g\gfunk-online.co.uk\user\htdocs\sendmail.php:3) in e:\domains\g\gfunk-online.co.uk\user\htdocs\sendmail.php on line 6
Can anyone help me please?
Thanks
This would work (i don't know if it's allowed sending header after mail()...):
Code: Select all
$headers = 'From: '. $email. "\r\n";
$check = mail("bookings@gfunk-online.co.uk", "Feedback Form Results", $message, $headers);
if($check == TRUE)
{
echo "Successfully sent! you can now check your email(".$to.")!";
}else{
echo "Error: the mail wasn't sent!";
}
header( "Location: http://www.gfunk-online.co.uk/confirmation.html" );I tried using that and I get the message
$headers = 'From: '. $email. "\r\n"; $check = mail("bookings@gfunk-online.co.uk", "Feedback Form Results", $message, $headers); if($check == TRUE) { echo "Successfully sent! you can now check your email(".$to.")!"; }else{ echo "Error: the mail wasn't sent!"; } header( "Location: http://www.gfunk-online.co.uk/confirmation.html" );
I put the code in the <? ?> tags and I get
Successfully sent! you can now check your email()!
Warning: Cannot modify header information - headers already sent by (output started at e:\domains\g\gfunk-online.co.uk\user\htdocs\sendmail.php:6) in e:\domains\g\gfunk-online.co.uk\user\htdocs\sendmail.php on line 10
$headers = 'From: '. $email. "\r\n"; $check = mail("bookings@gfunk-online.co.uk", "Feedback Form Results", $message, $headers); if($check == TRUE) { echo "Successfully sent! you can now check your email(".$to.")!"; }else{ echo "Error: the mail wasn't sent!"; } header( "Location: http://www.gfunk-online.co.uk/confirmation.html" );
I put the code in the <? ?> tags and I get
Successfully sent! you can now check your email()!
Warning: Cannot modify header information - headers already sent by (output started at e:\domains\g\gfunk-online.co.uk\user\htdocs\sendmail.php:6) in e:\domains\g\gfunk-online.co.uk\user\htdocs\sendmail.php on line 10
First of all, put
Code: Select all
and if you post PHP code (it makes the reading easier)!!!
Secndly, make sure you have "short tags" enabled in php.ini (short tags = "<? ?>").
Thirdly, try replacing the last header ("Location...") with:
[syntax=php]echo '<html><head><META HTTP-EQUIV="Refresh" CONTENT="0;URL=http://www.gfunk-online.co.uk/confirmation.html"></head></html>';[/syntax]Is this right?
Code: Select all
<?
$headers = 'From: '. $email. "\r\n";
$check = mail("bookings@gfunk-online.co.uk", "Feedback Form Results",
$message,
$headers); if($check == TRUE) { echo "Successfully sent! you can now check your email(".$to.")!";
}else{ echo "Error: the mail wasn't sent!"; } header( "echo '<html><head><META HTTP-EQUIV="Refresh" CONTENT="0;URL=http://www.gfunk-online.co.uk/confirmation.html"></head></html>'; " );
?>- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
You can redirect either by specifying a Location in the HTTP headers:
Or sending the page and using "Meta Refresh" to redirect:
Code: Select all
<?
header( 'Location: http://www.gfunk-online.co.uk/confirmation.html' );
?>Code: Select all
echo '<html><head><META HTTP-EQUIV="Refresh" CONTENT="0;URL=http://www.gfunk-online.co.uk/confirmation.html"></head></html>';(#10850)
try this:

Code: Select all
<?
$from = 'From: '.$email."\r\n".'Reply-To: '.$email;
mail( "bookings@gfunk-online.co.uk", "Feedback Form Results",
$message, $from);
header( "Location: http://www.gfunk-online.co.uk/confirmation.html");
?>1: what happens when you send a normal email to bookings@gfunk-online.co.uk
2: have you checked any junk mail folders or filters you have
3: try sending it to a hotmail address or something instead as a test
4: contact your hosts to see if they support the php "mail" command
2: have you checked any junk mail folders or filters you have
3: try sending it to a hotmail address or something instead as a test
4: contact your hosts to see if they support the php "mail" command
1.When I send an email to bookings@gfunk-online.co.uk it forwards it to another account I use.
2.Yes ive checked my junk mail folders
3.Ive tried using my hotmail address but it still doesnt work.
4.In the help section on my hosts site (streamline.net) it has a tutorial on using PHP scripts which ive followed but cant get them to work. Ive also emailed them but they say they cant help with scripting code.
2.Yes ive checked my junk mail folders
3.Ive tried using my hotmail address but it still doesnt work.
4.In the help section on my hosts site (streamline.net) it has a tutorial on using PHP scripts which ive followed but cant get them to work. Ive also emailed them but they say they cant help with scripting code.
- pawprint_net
- Forum Newbie
- Posts: 9
- Joined: Sat Jun 10, 2006 11:35 pm
- Location: Sechelt BC Canada
- Contact:
is YOUR isp doing any sort of email filtering/blocking?
You may need to look at using -f as a parameter to mail() to force the from in the envelope. Or look at adding a SPF record to the mail server from which the server is sending. I have run into both these as being a source of problems for sending mail from a web server to several major ISPs - Yahoo being the most notable.
See the PHP docs on the -f (some hosting platforms may not allow it - unless you have access to your ini files)
See http://spf.pobox.com/ for more info on SPF (also can be tricky to add depending on your access to the server)
You may need to look at using -f as a parameter to mail() to force the from in the envelope. Or look at adding a SPF record to the mail server from which the server is sending. I have run into both these as being a source of problems for sending mail from a web server to several major ISPs - Yahoo being the most notable.
See the PHP docs on the -f (some hosting platforms may not allow it - unless you have access to your ini files)
See http://spf.pobox.com/ for more info on SPF (also can be tricky to add depending on your access to the server)