Jump to content

sendmail errors not echoed on newline


phpnewbz

Recommended Posts

Hello all thanks in advance for any assistance it seems like sendmail doesn't work for anyone the first time around lol. I have tried inserting numerous "\r" and "\n" where they are supposed to go however when the redirect error page is displayed the errors are not listed on a newline. As well the error message for having an invalid email shows on the end of the list on the error page despite the fact that is second on the list of check_input function.

 

TIA much appreciation You will find the php and html code used below.

 

 

<?php
/* Set e-mail recipient */
$myemail  = "[email protected]";

/* Check all form inputs using check_input function */
$name = check_input($_POST['name'], "Enter your name \r");
$email    = check_input($_POST['email']);
$phone    = check_input($_POST['phone'], "Please include your telephone number \n");
$message = check_input($_POST['message'], "Write your message \n");

/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
{
    show_error("E-mail address not valid \n");
}



/* Let's prepare the message for the e-mail */
$message = "Hello!

Your contact form has been submitted by:

Full name: $name
E-mail: $email
Telephone: $phone
Message:
$message

End of message
";

/* Send the message using mail() function */
mail($myemail, $subject, $message);

/* Redirect visitor */
header('Location: thanks.html');
exit();

/* validate function*/
function check_input($data, $problem='')
{
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
    if ($problem && strlen($data) == 0)
    {
        echo ($problem); 
    }
    return $data;
}

function echo($myError)
{

?>

 

 

 

<html>
    <body>

    <b><?php echo $myError; ?></b><br />
    

    </body>
    </html>
<?php
exit();
}
?>

Link to comment
https://forums.phpfreaks.com/topic/264915-sendmail-errors-not-echoed-on-newline/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.