This is a discussion on PHP help for an amateur within the Php and MySQL forums, part of the Programming / Scripting / Coding category; Hi, I am new on here and having trouble developing a php script for a web to email form. When ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| | #1 (permalink) |
| Newbie | Hi, I am new on here and having trouble developing a php script for a web to email form. When I submit the form, the browser brings up a dialog box asking whether to open or save the 'sendmail.php' This is the problematic script: <?php $email = $_REQUEST['email'] ; $yourmessage = $_REQUEST['yourmessage'] ; $name = $_REQUEST['name'] ; $address = $_REQUEST['address'] ; $postcode = $_REQUEST['postcode'] ; $phoneno = $_REQUEST['phoneno'] ; $preferred_means_of_contact = $_REQUEST['preferred_means_of_contact'] ; mail( "myemail@mydomain.com", "Feedback Form Results", "$yourmessage", "From: $email", "$embody = $name $address $postcode $phoneno $preferred_means_of_contact" ) ; header( "Location: http://www.mydomain.co.uk/contact_thanks.html" ) ; ?> Any help would be greatly appreciated. |
| | |
| | #2 (permalink) |
| Super Moderator | I'd guess that your web server is not configured to execute PHP for a .php file. Is this your own PC or a webhost ?
__________________ Alex Monaghan - Monaghan Consultants Ltd Web hosting, ADSL, IT & Database consultancy Custom Web hosting on UK or USA servers using Linux (cPanel) or Windows (DotNetPanel) Mobile Phone Ringtones, Logos, Java Games & more |
| | |
| | #4 (permalink) |
| Super Moderator | Looks like a local config problem, bunged it onto my test server and it works OK with data passed in each field. Don't any any more time at the moment to help, maybe later if I have time.
__________________ Alex Monaghan - Monaghan Consultants Ltd Web hosting, ADSL, IT & Database consultancy Custom Web hosting on UK or USA servers using Linux (cPanel) or Windows (DotNetPanel) Mobile Phone Ringtones, Logos, Java Games & more |
| | |
| | #6 (permalink) | |
| Newbie | I have modified the script and removed '$embody'. So the script no looks like this: Code: <?
$email = $_REQUEST['email'] ;
$yourmessage = $_REQUEST['yourmessage'] ;
$name = $_REQUEST['name'] ;
$address = $_REQUEST['address'] ;
$postcode = $_REQUEST['postcode'] ;
$phoneno = $_REQUEST['phoneno'] ;
$preferred_means_of_contact = $_REQUEST['preferred_means_of_contact'] ;
mail( "myname@btinternet.com", "Feedback Form Results",
"$yourmessage", "From: $email", "$name", "$address", "$postcode", "$phoneno", "$preferred_means_of_contact");
header( "Location: http://www.mydomain.co.uk/contact_thanks.html" );
?>
Quote:
| |
| | |
| | #7 (permalink) |
| Super Moderator | Make the <?php the very first line in the file, otherwise the blank lines will be output prior to the php being executed. Once some content has been sent, then you are no longer able to send a header value. Alternatively you can look at output buffering in the PHP manual if you want to send headers in your code after the content.
__________________ Alex Monaghan - Monaghan Consultants Ltd Web hosting, ADSL, IT & Database consultancy Custom Web hosting on UK or USA servers using Linux (cPanel) or Windows (DotNetPanel) Mobile Phone Ringtones, Logos, Java Games & more |
| | |
| | #9 (permalink) |
| Newbie | I have cracked it!!!! Code: <?php
$email = $_REQUEST['email'] ;
$yourmessage = $_REQUEST['yourmessage'] ;
$name = $_REQUEST['name'] ;
$address = $_REQUEST['address'] ;
$postcode = $_REQUEST['postcode'] ;
$phoneno = $_REQUEST['phoneno'] ;
$actual_message = $yourmessage."\n--------------------\n".$name."\n".$address."\n".$postcode."\n".$phoneno."\n" ;
mail( "myname@btinternet.com", "Feedback Form Results",
"$actual_message", "From: $email");
header( "Location: http://www.mydomain.co.uk/contact_thanks.html" );
?>
Thanks for your help, Alex |
| | |
| | #10 (permalink) |
| Super Moderator | Good to see you're working now. Much better feeling when you resolve the issue yourself rather than having help
__________________ Alex Monaghan - Monaghan Consultants Ltd Web hosting, ADSL, IT & Database consultancy Custom Web hosting on UK or USA servers using Linux (cPanel) or Windows (DotNetPanel) Mobile Phone Ringtones, Logos, Java Games & more |
| | |