Hello,
- I want to add required fields to my contact form for “first name”, “last name”, “email address”, “type”, “subject” and “message”. 2) Furthermore, a check that email is typed in correctly with an @. 3) Also is there a way to design the “thank you” page or remain on the contact form page after message sent with a confirmation given there?
I don’t know much about PHP, and it took me more than one week to get the form below working. Therefore, I would so much appreciate the help if somebody may just add the required code.
In advance thank you so much.
PHP code:
[php]<?php
$companyname = $_POST[‘companyname’];
$firstname = $_POST[‘firstname’];
$lastname = $_POST[‘lastname’];
$email = $_POST[‘email’];
$phone = $_POST[‘phone’];
$website = $_POST[‘website’];
$type = $_POST[‘type’];
$subject = $_POST[‘subject’];
$message = $_POST[‘message’];
$formcontent=" Company name: $companyname \n First name: $firstname \n Last name: $lastname \n Phone: $phone \n Website: $website \n Type: $type \n Subject: $subject \n Message: $message";
$recipient = "[email protected]";
$subject = “x.com Contact Us”;
$mailheader = “From: $email \r\n”;
mail($recipient, $subject, $formcontent, $mailheader) or die(“Error!”);
echo “Thank you. Your e-mail has been sent.” . " -" . " Return Home";
?>
[/php]
HTML code:
[php]*
Required fields
Company name
First name*
Last name*
Email address*
Phone
Website
Type*
Customer
Media
Investor
Distributor
Wholesaler
Retailer
Other
Your message relates to*
Brand enquiry
Company information
Media enquiry
Investor enquiry
Buy products
Sell products
Website feedback
Other
Message
[/php]