<?php
if(isset($_POST['submit'])){
$to = "abc@gmail.com"; // this is your Email address
$from = $_POST['email']; // this is the sender's Email address
$first_name = $_POST['name'];
$mobile = $_POST['mobile'];
$companyname = $_POST['companyname'];
$companywebsite = $_POST['companywebsite'];
$country = $_POST['country'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";
$message = $first_name . " " . $companyname . " " . $from .
" " . $companywebsite . " " . $country . " " . $mobile .
" wrote the following:" . "\n\n" . $_POST['message'];
$message2 = "Here is a copy of your message " . $first_name . "\n\n" . $_POST['message'];
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
echo "Mail Sent. Thank you " . $first_name . ", we will contact you shortly.";
// You can also use header('Location: thank_you.php'); to redirect to another page.
}
?>
<html>
<head>
<meta charset="utf-8">
<title>Mail Form</title>
</head>
<body>
<form action="" method="post">
<table width="60%" cellspacing="10px" cellpadding="10px">
<tbody>
<tr>
<td>Name</td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td>Email</td>
<td><input type="e-mail" name="email"></td>
</tr>
<tr>
<td>Mobile</td>
<td><input type="text" name="mobile"></td>
</tr>
<tr>
<td>Company Name</td>
<td><input type="text" name="companyname"></td>
</tr>
<tr>
<td>Company Website</td>
<td><input type="text" name="companywebsite"></td>
</tr>
<tr>
<td>Country</td>
<td><input type="text" name="country"></td>
</tr>
<tr>
<td>Any Order or Query</td>
<td><textarea rows="5" name="message" cols="30"></textarea></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Submit" name="submit"></td>
</tr>
</tbody>
</table>
</form>
</body>
</html>