February 23, 201511 yr Hi Guys I am a complete newby to html & php and I am a bit lost. I have a form on my website but everytime that someone completes it I receive an email and all it shows is the following Name: Subject: Email: Message no other data is shown even when the form is completed. I have tried for two days now trying to get this resolved and I am getting nowhere fast. Can someone who knows what they are doing have a look at this for me and tell me how to fix it. (in easy terms please) My HTML for the page containing the form is: <!-- Author: W3layouts Author URL: http://w3layouts.com License: Creative Commons Attribution 3.0 Unported License URL: http://creativecommons.org/licenses/by/3.0/ --> <!DOCTYPE html> <html> <head> <title>Online Kitbag - We market your business online to get you more customers| Contact</title> <link href="css/bootstrap.css" rel='stylesheet' type='text/css' /> <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> <script src="js/jquery.min.js"></script> <!-- Custom Theme files --> <link href="css/style.css" rel="stylesheet" type="text/css" media="all" /> <!-- Custom Theme files --> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="keywords" content="ONLINE KITBAG, Websites, online presence, commercially viable, Smartphone and tablet Compatible website, modern, social media and search engine marketing" /> <script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script> <!--webfont--> <link href='http://fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,400italic,500,500italic,700,700italic,900,900italic' rel='stylesheet' type='text/css'> </head> <body> <!-- header-section-starts --> <div class="header"> <div class="container"> <div class="logo"> <a href="index.html"><img src="images/logo.png" class="img-responsive" alt="" /></a> </div> <div class="header-right"> <h4><i class="phone"></i>(0333) 301 3498</h4> <span class="menu"></span> <div class="top-menu"> <ul> <li><a href="index.html">Home</a></li> <li><a href="about.hmtl">About Us</a></li> <li><a href="services.html">Services</a></li> <li><a href="blog.html">Knowledge</a></li> <li><a class="active" href="#">Contact Us</a></li> </ul> </div> <!-- script for menu --> <script> $( "span.menu" ).click(function() { $( ".top-menu" ).slideToggle( "slow", function() { // Animation complete. }); }); </script> <!-- script for menu --> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <script> $("#contactform").submit(function(){ $.get("contactsend.php", function(data){ alert(data); }) return false; }) </script> </div> <div class="clearfix"></div> </div> </div> <!-- header-section-ends --> <div class="content"> <div class="contact about-desc"> <h3>Contact-Information</h3> <div class="container"> <div class="row"> <div class="col-md-8 contact_left"> <h4>We Want to hear from you</h4> <p class="m_6">Send us your feedback – anything that's on your mind – whether good or bad, compliments or criticisms, we want to hear it. If something is bothering you, we'll work to fix it. If you like something we're doing, we'll continue to do it. Your insights are critically important, and we want to make sure we're continually raising the bar on your experience with <strong>Online</strong> Kitbag.</p> <div class="contact_grid contact_address"> <h5>Online Kitbag Limited</h5> <p>The Alexander Suite</p> <p>Silk Point</p> <p>Queens Avenue</p> <p>Macclesfield</p> <p>SK10 2BB</p> <p> </p> <p>Telephone : (0333) 301 3498</p> <p>Email : <a href="mailto:hello@onlinekitbag.com">hello@onlinekitbag.com</a></p> </div> </div> <div class="col-md-4"> <div class="contact_right"> <div class="contact-form_grid"> <form action="send.php" method="GET" enctype='application/x-www-form-urlencoded'> <input type="text" class="textbox" value="name" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'name';}"> <input type="text" class="textbox" value="email" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'email';}"> <input type="text" class="textbox" value="subject" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'subject';}"> <textarea value="message:" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'message';}">Message</textarea> <input type="submit" value="Send"> </form> </div> </div> </div> </div> </div> </div> </div> </div> <div class="map s-map"> <iframe src="https://www.google.com/maps/embed?pb=!1m14!1m8!1m3!1d2385.974876241252!2d-2.1162188!3d53.272069800000004!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x487a4969cc7d0877%3A0xd2c40bc63ed1378e!2sMacclesfield%2C+Cheshire+East+SK10+2BB!5e0!3m2!1sen!2suk!4v1423748504908" frameborder="0" style="border:0"></iframe> <div class="map-layer"></div> </div> </div> <div class="footer text-center"> <div class="social-icons"> <a href="#"><i class="facebook"></i></a> <a href="https://twitter.com/onlinekitbag"><i class="twitter"></i></a> <a href="#"><i class="googlepluse"></i></a> </div> <div class="copyright"> <p>Copyright © 2015 All rights reserved | <strong>Online</strong> <a href="http://onlinekitbag.com"> Kitbag</a></p> </div> </div> </body> </html> the PHP I have is: <?php $emailFrom = "Hello@onlinekitbag.com"; $emailTo = "hello@onlinekitbag.com"; $subject = "Website contact"; $name = Trim(stripslashes($_GET['name'])); $subject = Trim(stripslashes($_GET['subject'])); $email = Trim(stripslashes($_GET['email'])); $message = Trim(stripslashes($_GET['message'])); // validation $validationOK=true; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } // prepare email body text $Body = ""; $Body .= "name: "; $Body .= $name; $Body .= "\n"; $Body .= "subject: "; $Body .= $subject; $Body .= "\n"; $Body .= "email: "; $Body .= $email; $Body .= "\n"; $Body .= "message: "; $Body .= $message; $Body .= "\n"; // send email $success = mail($emailTo, $subject, $Body, "From: <$emailFrom>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.html\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; } ?> Please can someone help me put this right. Many thanks in advance for your expertise contact.html send.php Edited February 23, 201511 yr by webdesigner93 Please use code tags
February 23, 201511 yr You have to set a name on your input fields. <input type="text" class="textbox" value="name" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'name';}"> Should be <input type="text" class="textbox" name="name" value="name" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'name';}"> Good luck!
February 23, 201511 yr Just a quck observation off topic (adding the name attributes suggested by EpicWebs should solve your problem) I'm just thinking you should probably use post insted of get as method. Especially if the message contains personal/sensitive information. With the get method all the submited data is stored in what will be a very long url. Imagine what would happen if the user hits a share button after submitting the form. Edited February 23, 201511 yr by Nillervision
February 24, 201511 yr Just a quck observation off topic (adding the name attributes suggested by EpicWebs should solve your problem) I'm just thinking you should probably use post insted of get as method. Especially if the message contains personal/sensitive information. With the get method all the submited data is stored in what will be a very long url. Imagine what would happen if the user hits a share button after submitting the form. Expanding on the above by Nillervision normally GET is more used say for like a search bar if you are submitting a form that contains stuff like Name,E-mail etc.. you would almost always go with the POST method
February 24, 201511 yr It would also be worth looking into the filter_input function it's really powerful. http://php.net/manual/en/function.filter-input.php
Create an account or sign in to comment