BMadden Posted January 12, 2016 Share Posted January 12, 2016 Hi I am a newbie with PHP. I created a contact form following a tutorial online and have uploaded the index.html and contact-form.php form to a server with php enabled. I am getting an error message Warning! Please fill all the fields. ”; } else { mail($to,$subject,$msg,”From:”.$email); echo “ I am wondering if anyone can advise me? The PHP: <?php $to="calming1@yahoo.co.uk";/*Your Email*/ $subject="Message from the website"; $date=date("l, F jS, Y"); $time=date("h:i A"); $name=$_REQUEST['name']; $email=$_REQUEST['email']; $message=$_REQUEST['message']; $msg=" Message sent from website form on date $date, hour: $time.\n Name: $name\n Email: $email\n Message: $message\n "; if($email=="") { echo "<div class='alert alert-danger'> <a class='close' data-dismiss='alert'>×</a> <strong>Warning!</strong> Please fill all the fields. </div>"; } else { mail($to,$subject,$msg,"From:".$email); echo "<div class='alert alert-success'> <a class='close' data-dismiss='alert'>×</a> <strong>Thank you for your message!</strong> </div>"; } ?> HTML <form id="contact" class="form-inline" action="contact-form.php" method="post" accept-charset="utf-8"> <div class="form-group pull-left"> <label class="sr-only" for="name">Name</label> <input type="text" class="form-control" id="name" placeholder="Name" name="name"> </div> <div class="form-group pull-right"> <label class="sr-only" for="email">Email</label> <input type="email" class="form-control" id="email" placeholder="Email" name="email"> </div> <textarea class="form-control pull-left" rows="8" placeholder="Message" name="message"></textarea> <button type="submit" class="btn pull-right">Send email</button> </form> Quote Link to comment https://forums.phpfreaks.com/topic/300298-contact-form/ Share on other sites More sharing options...
ginerjm Posted January 12, 2016 Share Posted January 12, 2016 (edited) Hmmm, I copied your files and uploaded them to my server. They worked just fine when I filled in all the fields. When I didn't though the message came out with a bit of garbage at the start of it. That anchor tag I suspect. So I removed it. What is the purpose of the anchors in front of your messages, or don't you know? PS - It is recommended to use the appropriate array to search for your inputs. Since you know it is coming from $_POST, why do you look in $_REQUEST? Edited January 12, 2016 by ginerjm Quote Link to comment https://forums.phpfreaks.com/topic/300298-contact-form/#findComment-1529541 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.