Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Brandon Beard
9,495 PointsNeed help with Third parties libraries!!
my code looks like this:
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") { $name = trim($_POST["name"]); $email = trim($_POST["email"]); $message = trim($_POST["message"]);
if ($name == "" OR $email == "" OR $message == ""){
echo "Please specify a value for name email address, and message.";
exit;
}
foreach($_POST as $value){
if( stripos($value,'Content-Type')!== FALSE ){
echo "There was a problem with the inforamation you entered.";
exit;
}
}
if($_POST["address"] != ""){
echo "Your form submission has an error!";
exit;
}
require_once("inc/phpmailer/class.phpmailer.php");
$mail = new PHPMailer();
if (!$mail->ValidateAddress($email)){
echo "Your form submission has an error.";
}
$email_body = "";
$email_body = $email_body . "Name: " . $name . "\n";
$email_body = $email_body . "Email: " . $email . "\n";
$email_body = $email_body . "Message: " . $message;
header("Location: contact.php?status=thanks");
exit;
}
?>
Validation wise everything works except when i try to enter a false email. When that happens i get
Cannot modify header information - headers already sent by....
Please help so i can move on.
1 Answer
Brandon Beard
9,495 Pointsforgot to add exit after the last echo