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  = "me@anywhere.com";

/* 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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.