I've looked through a lot of posts on a lot of different websites, including this one and still can't figure out whats going on. First of all I'm not getting an email to my desired email in put in the PHP file. My redirect is also not going the html page I designated, instead it goes to the PHP file, which is just a blank page when viewed.
HTML
<form action="result.php" method="post" enctype="text/plain" name="form1"> <table width="500" border="0" align="center" cellspacing="0"> <tr> <td>Name:</td> <td><input name="name" type="text" size="30" maxlength="30"></td> </tr> <tr> <td>Email:</td> <td><input name="email" type="text" size="30" maxlength="50" placeholder="[email protected]"></td> </tr> <tr> <td>Phone:</td> <td><input name="phone" type="text" size="30" maxlength="20"></td> </tr> <tr> <td>Inquiry type:</td> <td><select name="type"> <option value="1" selected>Residential Inquiry</option> <option value="2">Small Business Inquiry</option> <option value="3">Web Design Inquiry</option> <option value="4">Existing Client Inquiry</option> </select></td> </tr> <tr> <td>Message:</td> <td><textarea name="message" cols="45" rows="5"></textarea></td> </tr> <tr> <td> </td> <td><input name="submit" type="submit" value="Submit" /> <input name="reset" type="reset" value="Reset" /></td> </tr> </table> </form> PHP
<?php $name = $_POST['name']; $visitor_email = $_POST['email']; $phone = $_POST['phone']; $subject = $_POST['type']; $message = $_POST['message']; if(IsInjected($visitor_email)) { echo "Bad email value!"; exit; } $email_from = '[email protected]';//<== update the email address $email_subject = "$subject"; $email_body = "$message" + "phone"; $to = "[email protected]"; //<== update the email address $headers = "From: $email_from \r\n"; $headers = "Reply-To: $visitor_email \r\n"; //Send the email! mail($to,$email_subject,$email_body,$headers); //done. redirect to thank-you page. header('Location: http://www.example.com/example.html'); // Function to validate against any email injection attempts function IsInjected($str) { $injections = array('(\n+)', '(\r+)', '(\t+)', '(%0A+)', '(%0D+)', '(%08+)', '(%09+)' ); $inject = join('|', $injections); $inject = "/$inject/i"; if(preg_match($inject,$str)) { return true; } else { return false; } } ?>
text/plain.