shaky14
04-10-2005, 07:55 PM
How do I set up form mail where all the fields are required before it is suybmitted?
|
Click to See Complete Forum and Search --> : Formmail scripting shaky14 04-10-2005, 07:55 PM How do I set up form mail where all the fields are required before it is suybmitted? JayM 04-11-2005, 10:22 AM Ok. Here I go at my first attempt to help someone in php! First you want to write your actual form. <FORM ACTION="sendmail.php" METHOD="post"> All fields are required:<br> name: <input type="text" name="name"><br /> eMail: <input type="text" name="email"><br /> subject: <input type="text" name="subject"><br /> content: <textarea type="text" name="content"></textarea><br /> <input type="submit" name="submit" value="email!"> </FORM> Your php script should look like this: <?php @extract($_POST); $name = stripslashes($name); $email = stripslashes($email); $subject = stripslashes($subject); $content = stripslashes($content); If ($name != "" && $email != "" && $subject != "" && $content != "") { mail('your_email@address.com',$subject,$content,"From: $name <$email>"); header("location:thankyou.html"); } else { echo ("<script language='javascript'> alert ('Please fill in all fields before submitting');</script>"); } ?> Test that out see if it works. Again, i'm a beginner in PHP. If that doesn't work some of the pros on this board will help you. If you would like to tell your visitor specifically which field they did not fill out there you can use the Switch() case: method. Edit: By the way, this script (provided it works) will not run on a Windows system unless you have modified your php.ini file. webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |