Ajith Posted January 12, 2015 Share Posted January 12, 2015 Hello, I need a contact form with fields: Name: Email: Phone: Message: I have html contact form but when a visitor clicks on submit button then a pop up says thnq for contacting us and he need to be on the same page. the details has to get in mail to me. Quote Link to comment https://forums.phpfreaks.com/topic/293864-need-help-with-contact-form/ Share on other sites More sharing options...
chriscloyd Posted January 12, 2015 Share Posted January 12, 2015 <form action="" method="post" name="contact"> <input type="text" name="name" placeholder="First and Last Name" /><br /> <input type="email" name="email" placeholder="Email Address" /><br /> <input type="text" name="phone" placeholder="Phone Number" /><br /> <textarea name="message"> Type Your Message Here </textarea><br /> <input type="submit" name="submit" value="Send" /><br /> </form> <?php if(isset($_POST['submit'])){ $name = $_POST['name']; $email = $_POST['email']; $phone = $_POST['phone']; $message = $_POST['message']; $to = 'Your Email Address'; $subject = 'Contact Message From - ' . $name; $body = "Name: {$name}\n Email: {$email}\n Phone: {$phone}\n Message:\n {$message}"; mail($to, $subject, $body); } Quote Link to comment https://forums.phpfreaks.com/topic/293864-need-help-with-contact-form/#findComment-1502648 Share on other sites More sharing options...
wezhind Posted January 12, 2015 Share Posted January 12, 2015 Note, though the code above from chriscloyd should work as a contact form that sends you an email - you MUST apply some form of security to the data posted by the user otherwise you'll swiftly find your database corrupted or your contact form becomes used for sending spam mail. ALWAYS, always validate the user somehow - even if its just one of those annoying captchas. Good luck. Quote Link to comment https://forums.phpfreaks.com/topic/293864-need-help-with-contact-form/#findComment-1502676 Share on other sites More sharing options...
davidannis Posted January 12, 2015 Share Posted January 12, 2015 Unless you are using this as a way to learn to code, instead of reinventing the wheel, I would suggest using a form processor that is already written and tested. I have used the one from tectite before. Quote Link to comment https://forums.phpfreaks.com/topic/293864-need-help-with-contact-form/#findComment-1502681 Share on other sites More sharing options...
Ajith Posted January 24, 2015 Author Share Posted January 24, 2015 guyz thnq very much for ur help. i had small problem. if any one submits the form then it is nt sending me the mail. and also a pop has to come saying thanks for contacting us. plz help me with the code Quote Link to comment https://forums.phpfreaks.com/topic/293864-need-help-with-contact-form/#findComment-1504079 Share on other sites More sharing options...
wezhind Posted February 2, 2015 Share Posted February 2, 2015 (edited) Ensure you have set the correct email address in the $to variable. It's difficult to know what your issue is unless you post your current code though. http://php.net/manual/en/function.mail.php http://email.about.com/od/emailprogrammingtips/qt/How_to_Send_Email_from_a_PHP_Script.htm http://www.w3schools.com/php/func_mail_mail.asp Every one of the above pages explains how to use the mail() function. I advise care regards security once more. 'Popups' are achievable by several means - again, a short trawl through the first page of results from your favourite search-engine will provide you with examples on how to achieve this. However, it would be worth bearing in mind from a UX point of view, that the method of displaying an item the user has to dismiss before they can access the page's content, should be used only at apposite times. i.e. if a user is about to delete something that will be irretrievable. Why can't you just show the 'Thank You' on the page in a highly visible manner? Anyway, it's not for me to dictate your strategy, I merely offer information. If you do continue the 'popup' route, you might consider jQuery or some other javascript library. Good luck. Edited February 2, 2015 by wezhind Quote Link to comment https://forums.phpfreaks.com/topic/293864-need-help-with-contact-form/#findComment-1504534 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.