Howdy_McGee Posted August 19, 2010 Share Posted August 19, 2010 Ok, I'm trying to get a PHP form to work but as soon as I put in the variable "$company" it just stop sending.... Doesn't give me a error or anything like that it just doesn't send it to my email.Obviously I've hidden my email in the below code:HTML <form method="post" action="sendmail.php"> Your Name: <input name="name" type="text" size="70" /><br /> Company: <input name="company" type="text" size="70" /><br /> E-Mail: <input name="email" type="text" size="70" /> <br /> <br /> <textarea name="message" rows="15" cols="40"> </textarea><br /> <input type="submit" /></form> PHP <?php $name = $_POST['name']; $company = $_POST['company']; $email = $_POST['email']; $message = $_POST['message']; mail( "hidden@email.com", "Feedback Form Results", $name, $message, $company, "From: $email"); header( "Location: http://www.yahoo.com" );?> Link to comment Share on other sites More sharing options...
justsomeguy Posted August 19, 2010 Share Posted August 19, 2010 You're not using the mail function correctly, check the examples:http://www.php.net/manual/en/function.mail.phpIt has 3 required parameters and 2 optional parameters, you don't just pass it whatever you want and expect it to know what you want it to do. Link to comment Share on other sites More sharing options...
Howdy_McGee Posted August 19, 2010 Author Share Posted August 19, 2010 It has 3 required parameters and 2 optional parameters, you don't just pass it whatever you want and expect it to know what you want it to do.That can't be right, I've seen forms with 3 required and multiple optional as in more than 2... Link to comment Share on other sites More sharing options...
justsomeguy Posted August 19, 2010 Share Posted August 19, 2010 It is right, I'm not talking about the form, I'm talking about the mail function. The parameters are the to address, the subject, the body, additional headers, and additional parameters. Check the manual page. Anything you want in the email text goes in the body parameter. Link to comment Share on other sites More sharing options...
Howdy_McGee Posted August 19, 2010 Author Share Posted August 19, 2010 Check the manual page. Anything you want in the email text goes in the body parameter.body parameter as in HTML body parameter? like in the PHP manual example?$message = '<html><head> <title>Birthday Reminders for August</title></head><body> <p>Here are the birthdays upcoming in August!</p> <table> <tr> <th>Person</th><th>Day</th><th>Month</th><th>Year</th> </tr> <tr> <td>Joe</td><td>3rd</td><td>August</td><td>1970</td> </tr> <tr> <td>Sally</td><td>17th</td><td>August</td><td>1973</td> </tr> </table></body></html>'; So I can still store data in variables that i create in PHP - I just need to put them in the body and store it all under '$message'? Link to comment Share on other sites More sharing options...
justsomeguy Posted August 19, 2010 Share Posted August 19, 2010 Right, anything which you want to appear in the email goes in the third parameter. It doesn't need to be HTML text, that's just the example for sending an HTML email. Link to comment Share on other sites More sharing options...
Howdy_McGee Posted August 23, 2010 Author Share Posted August 23, 2010 lol to be honest I'm a little surprised on how easy it is making a form with PHP.Are things like these necesseties? enctype="multipart/form-data" accept-charset="UTF-8" spoke too soon.I tried putting said variables into the PHP like so $message = 'Name: ' $name; And it will error out on that line. So I try to put it in HTML like so $message ="<html> <body> <table> <tr> <td>Name = 'Name:' $name</td> </tr> </table> </body></html>"; And it will also error out. What am I missing here? Link to comment Share on other sites More sharing options...
justsomeguy Posted August 23, 2010 Share Posted August 23, 2010 What is $name? You only need the enctype if you're doing a file upload, otherwise the default is fine. Link to comment Share on other sites More sharing options...
thescientist Posted August 23, 2010 Share Posted August 23, 2010 $message = 'Name: ' $name; that will throw an error because you are missing the concatenation operator. $message = 'Name: ' . $name; Link to comment Share on other sites More sharing options...
Howdy_McGee Posted August 23, 2010 Author Share Posted August 23, 2010 What is $name? You only need the enctype if you're doing a file upload, otherwise the default is fine.$name is the variable. Thanks for your help guys. Now I just need to check out how to validate forms. ^.^ I'm getting the hang of this. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.