homepage Welcome to WebmasterWorld Guest from 23.22.173.58
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Email form and redirect back to the site
Email form and redirect back to the site
ansokclifford



 
Msg#: 4400478 posted 12:12 pm on Dec 22, 2011 (gmt 0)

hi i'm a newbie on php and i want to create a for that will collect the name and contact number of the person and send it to my email.

can anyone help me on this?
i've tried this code but doesn't send email to my email account
<?php if(isset($_POST['submit'])) {
$to = "myemail@sample.com"; $name = $_POST['name']; $contact = $_POST['contactl']; $body = "From: $name\n E-Mail: $contact; echo "Data has been submitted to $to!"; mail($to, $body);} else { echo "error!";} ?>can you help me on this?

Thanks

 

rocknbil

WebmasterWorld Senior Member rocknbil us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 4400478 posted 5:10 pm on Dec 22, 2011 (gmt 0)

It's possibly because you're missing a from, which goes in the headers (usually composed as the variable $headers,) and many systems won't send mail without a valid from email. Also the second parameter is subject, you have $body in it. Try one of the examples in the documentation [php.net].

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved