-2

I've attempted at a contact us form in PHP, now when it's submitted and user data it not filled in the form should refer the user back to fill it out again. so the code i currently have is:

 <?php
  $all = 'All fields are required, please fill <a href="\">the form</a> again.'
$action=$_REQUEST['action'];
if ($action=="")    /* display the contact form */
    {
    ?>
    <form  action="" method="POST" enctype="multipart/form-data">
    <input type="hidden" name="action" value="submit">
    Your name:<br>
    <input name="name" type="text" value="" size="30"/><br>
    Your email:<br>
    <input name="email" type="text" value="" size="30"/><br>
    Your message:<br>
    <textarea name="message" rows="7" cols="30"></textarea><br>
    <input type="submit" value="Send email"/>
    </form>
    <?php
    } 
else                /* send the submitted data */
    {
    $name=$_REQUEST['name'];
    $email=$_REQUEST['email'];
    $message=$_REQUEST['message'];
    if (($name=="")||($email=="")||($message==""))
        {
        echo $all;
        }
    else{       
        $from="From: $name<$email>\r\nReturn-path: $email";
        $subject="Message sent using your contact form";
        // mail("email@email.com", $subject, $message, $from);
        echo "Email sent!";
        }
    }  
?>

Now for some reason where i'm using All fields are required, please fill <a href="\">the form</a> again. it does not hide its self it shows up which i find very strange?

Here is the live link to further explain

JasonReynolds
  • 17
  • 1
  • 7

1 Answers1

0

I assume you have mistakes in the code, second string should be fiished with ";"