5
Contributors
12
Replies
56
Views
4 Years
Discussion Span
Last Post by mmcdonald
Featured Replies
  • well, umm, [no, it isnt,]( http://www.w3.org/TR/2010/WD-html-markup-20101019/datatypes.html#datatypes) > e-mail address # > Any string that matches the following [ABNF] production: > 1*( atext / "." ) "@" ldh-str 1*( "." ldh-str )…where atext is as defined in [RFC 5322], and ldh-str is as defined in [RFC 1034]. > > Examples: > … Read More

0
<?php
    if (empty($_POST) === false) {
        $errors = array();

        $name       = $_POST['name'];
        $email      = $_POST['email'];
        $message    = $_POST['message'];

        if (empty($name) === true || empty($email) === true || empty($message) === true) {
            $errors[] = 'Name, email and message are required';
        }else{
            if (filter_var($email,FILTER_VALIDATE_EMAIL) === false) {
                $errors[] = 'That\'s not a valid email';
            }

            if (ctype_alpha($name) === false) {
                $errors[] = 'Name must only contain letters';
            }
        }

        if (empty($errors) === true){
            mail('test.powerm.ma', 'Contact form', $message, 'From: ' . $email);
            header('Location: index.php?sent');
            exit();
        }
    }
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>

    <?php 
        if (empty($errors) === false) {
            echo '<ul>';
            foreach($errors as $errors) {
                echo '<li>', $errors, '</li>';
            }
            echo '</ul>';
        }
    ?>
    <form action="" method="post">
        <p>
            <label for="name">Name:</label><br>
            <input type="text" name="name" id="name" <?php if(isset($_POST['name']) === true) {echo 'value=', strip_tags($_POST['name']), '"'; }?>>
        </p>

        <p>
            <label for="email">Email:</label><br>
            <input type="text" name="email" id="email" <?php if(isset($_POST['email']) === true) {echo 'value=', strip_tags($_POST['email']), '"'; }?>>
        </p>

        <p>
            <label for="message">Message:</label><br>
            <textarea name="message" id="message"><?php if(isset($_POST['message']) === true) {echo  strip_tags($_POST['message']); }?></textarea>
        </p>

        <p>          
            <input type="submit" value="Submit" />
        </p>
    </form>
</body>
</html>
0

Output PHP errors and post them here please or get them from your error.log file. If you're local it's php_error_log

0

there are no errors but when i check my box i dont find the email

0

it's just to test my contact form, but it's a valid mail

1

well, umm, no, it isnt,

e-mail address #
Any string that matches the following [ABNF] production:
1( atext / "." ) "@" ldh-str 1( "." ldh-str )…where atext is as defined in [RFC 5322], and ldh-str is as defined in [RFC 1034].

Examples:

foo-bar.baz@example.com

must contain @

Edited by almostbob

0

I copied your code and just changed the email address to mine. I got the email fine.
Have you tried checking your spam or junk folder?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.