Making a contact form is quite easy, but I will just share with you PHP/HTML noobs how to create one. The way this works is you have the form on your website, the person puts in their email, name, subject, and message and hits send message. You will then receive their message via email to reply to them. I recommend using Sublime Text 2 to code, as it is great for organization. (Example of a Contact Form: http://i.imgur.com/ZHRZFJ3.png) Step 1 - The PHP Code Insert this code into a new Sublime Text document, Notepad document, etc. Spoiler <?php // Check for empty fields if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['phone']) || empty($_POST['message']) || !filter_var($_POST['email'],FILTER_VALIDATE_EMAIL)) { echo "No arguments Provided!"; return false; } $name = $_POST['name']; $email_address = $_POST['email']; $phone = $_POST['phone']; $message = $_POST['message']; // Create the email and send the message $to = 'yourname@yourdomain.com'; // Add your email address inbetween the '' replacing yourname@yourdomain.com - This is where the form will send a message to. $email_subject = "New Mail: $name"; $email_body = "You have received a new message from your website contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email_address\n\nPhone: $phone\n\nMessage:\n$message"; $headers = "From: noreply@yourdomain.com\n"; // This is the email address the generated message will be from. We recommend using something like noreply@yourdomain.com. $headers .= "Reply-To: $email_address"; mail($to,$email_subject,$email_body,$headers); return true; ?> Fill out all the info to match your info. Save as contact.php [hr] Step 2 - The HTML You will need to create a form in your HTML page, and that requires just some small experience in HTML. Here is an example code of a form, just bend it to match your page: Spoiler <form name="sentMessage" id="contactForm" novalidate> <div class="row"> <div class="col-md-6"> <div class="form-group"> <input type="text" class="form-control" placeholder="Your Name *" id="name" required data-validation-required-message="Please enter your name."> <p class="help-block text-danger"> </div> <div class="form-group"> <input type="email" class="form-control" placeholder="Your Email *" id="email" required data-validation-required-message="Please enter your email address."> <p class="help-block text-danger"> </div> <div class="form-group"> <input type="tel" class="form-control" placeholder="Your Phone *" id="phone" required data-validation-required-message="Please enter your phone number."> <p class="help-block text-danger"> </div> </div> <div class="col-md-6"> <div class="form-group"> <textarea class="form-control" placeholder="Your Message *" id="message" required data-validation-required-message="Please enter a message."></textarea> <p class="help-block text-danger"> </div> </div> <div class="clearfix"></div> <div class="col-lg-12 text-center"> <div id="success"></div> <button type="submit" class="btn btn-xl">Send Message</button> </div> </div> </form> Tip: you don't really need any of the HTML above other than the <form> tag and it's elements, submit button, and the textareas. After inserting the HTML into your page and fitting it to look nice, save it and test out that contact form! [hr] Hope I helped anyone struggling with PHP development!
To add onto this: To prevent bots from spamming up your contact form page add in things such as - $email_address = $_POST['email']; $email_check = ''/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if $email_address,$email_check)) { $error_message .= 'This email holds invalid characters, please change it to an existing email.'; } This will prevent people using fake emails to harass you or flood your email.