August 12, 201412 yr Hi, I'm working on what should be a simple form. I guess I just don't know how to handle radio button selections which I need to send to an email address. When I select an option and hit submit, the browser finds the php file (contact.php) but nothing happens. So I guess the problem is with the php file - everything seems to be working in the html (I think). This is where I'm at so far: http://www.clearstreamdesign.co.uk/form/formtest.html Here's the html and below that the php I'm using. Any advice really appreciated. <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Name The Cow</title> <link href="css/formstyle.css" rel="stylesheet"> <script type="text/javascript" src="js/blinking_text.js"></script> </head> <body> <div id="formbox"> <form method="post" action="contact.php"> <div class="tag">Please Choose A Name</div> <div class="button-holder"> <input type="radio" id="radio-2-1" name="cowname" value="buttercup" class="regular-radio big-radio" /><label for="radio-2-1"></label><br /><br /> <input type="radio" id="radio-2-2" name="cowname" value="clarabell" class="regular-radio big-radio" /><label for="radio-2-2"></label><br /><br /> <input type="radio" id="radio-2-3" name="cowname" value="delilah" class="regular-radio big-radio" checked /><label for="radio-2-3"></label><br /><br /> <input type="radio" id="radio-2-4" name="cowname" value="emily" class="regular-radio big-radio" /><label for="radio-2-4"></label><br /><br /> <input type="radio" id="radio-2-5" name="cowname" value="esme" class="regular-radio big-radio" /><label for="radio-2-5"></label><br /><br /> <input type="radio" id="radio-2-6" name="cowname" value="eva" class="regular-radio big-radio" /><label for="radio-2-6"></label><br /><br /> </div> <div class="label-holder"> <span class="formlabel">BUTTERCUP</span> <p><span class="formlabel">CLARABELL</span> <p><span class="formlabel">DELILAH</span></p> <p><span class="formlabel">EMILY</span></p> <p><span class="formlabel">ESME</span></p> <p><span class="formlabel">EVA</span></p> </div> <p><div class="form-group"> <button type="submit" class="myButton">Submit</a></button> <button type="reset" class="myButton">Reset</a></button></p> </div></p> </form> </form> </div> </div> </div></div> <div id="terms"> </body> </html> And the PHP <?php $EmailFrom = "Form entry"; $EmailTo = "me@gmail.com"; $Subject = "Name Cow Entry"; $Cowname = Trim(stripslashes($_POST['cowname'])); // prepare email body text $Body = ""; $Body .= "EmailFrom: "; $Body .= $EmailFrom; $Body .= "\n"; $Body .= "Subject: "; $Body .= $Subject; $Body .= "\n"; $Body .= "Cowname: "; $Body .= $Cowname; $Body .= "\n"; // send email $success = mail($EmailTo, $Subject, $ Body, $Cowname, "From: <$EmailFrom>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=messagesent.html\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=messagenotsent.html\">"; function check_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } } ?>
August 12, 201412 yr Author If it's a case of $Body or $ Body, how come an error message isn't thrown up. Browsers do that don't they? But I'll try that obvioulsy. Thanks.
Create an account or sign in to comment