Hello,

I have this inquiry form. I wish to capture the fields and email via php script. Can anyone help me in doing that?

It uses html text field, select and textarea form elements.. In select name I wish to capture and email the option selected.

<form action="#" method="get" name="form1">
<label for="name">Name:</label><input name="name" type="text" /><br /><br />
<label for="email">Email:</label><input name="email" type="text" /><br /><br />
<label for="phone">Phone:</label><input name="phone" type="text" /><br /><br />
<label for="cmcenquiryform">Enquiry For:</label>

<select name="cmcenquiryform">
<option>Joining Courses</option>
<option>Franchisee</option>
<option>Corporate Training</option>
<option>Others</option>
</select><br /><br />
<label for="query">Query:</label><textarea name="query" cols="25" rows="5"></textarea><br /><br />

<input name="enquire" type="submit" value="Enquire Now!" class="submit"/><br /><br />

</form>

Thanks a million in advance

Best Regards
K G

First created a php file named for example "process.php"
Set this file as your action within the <form> tag

The options you made do not have values:

<select name="cmcenquiryform">
<option value="Joining Courses">Joining Courses</option>
<option value="Franchisee">Franchisee</option>
<option value="Corporate Training">Corporate Training</option>
<option value="Others">Others</option>
</select>

Retrieving the form values using php is very easy, and is the same for every type of input, so if someone selects "Joining Courses" the value of cmcenquiryform is "Joining Courses". A small example for process.php:

<?php
if (isset($_POST['name'])) {

   // If the value of name is not null:

   $name = $_POST['name'];
   echo "You entered as name: ".$name;

} else {

   // If the value is null:

   echo "You did not enter a name!";

}
?>

~G

Hello,

I have this inquiry form. I wish to capture the fields and email via php script. Can anyone help me in doing that?

It uses html text field, select and textarea form elements.. In select name I wish to capture and email the option selected.

<form action="#" method="get" name="form1">
<label for="name">Name:</label><input name="name" type="text" /><br /><br />
<label for="email">Email:</label><input name="email" type="text" /><br /><br />
<label for="phone">Phone:</label><input name="phone" type="text" /><br /><br />
<label for="cmcenquiryform">Enquiry For:</label>

<select name="cmcenquiryform">
<option>Joining Courses</option>
<option>Franchisee</option>
<option>Corporate Training</option>
<option>Others</option>
</select><br /><br />
<label for="query">Query:</label><textarea name="query" cols="25" rows="5"></textarea><br /><br />

<input name="enquire" type="submit" value="Enquire Now!" class="submit"/><br /><br />

</form>

Thanks a million in advance

Best Regards
K G

if you want to send your inquiry form on your mail then use the below script:
form.php

<?PHP
if (isset($_POST['enquire'])) //Getting data from form.
{

$name = $_POST['name'];
$email = $_POST['email'];
$phone_no = $_POST['phone'];
$inqfor = $_POST['cmcenquiryform'];
$query = $_POST['query'];

$to = 'your email goes here'; //Change this with your email address.
$sunject = "Inquery form Submitted by $name"; //your subject goes here.
$message = "<html>
<head>
  <title>Inquery form Submitted by $name</title>
</head>
<body>
  <p>Here are the Inquiry Received by User!</p>
  <table>
    <tr>
      <td>Name:</td><td>$name</td>
    </tr>
    <tr>
      <td>Email:</td><td>$email</td>
    </tr>
    <tr>
      <td>Phone Number:</td><td>$phone_no</td>
    </tr>
    <tr>
      <td>Inquiry for:</td><td>$inqfor</td>
    </tr>
    <tr>
      <td>Query:</td><td>$query</td>
    </tr>
  </table>
</body>
</html>"; //Your Message Goes Here. edit with your requirement.

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: $to' . "\r\n";
$headers .= 'From: $name <$email>' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);

}

?>

<form action="form.php" method="POST" name="form1">
<label for="name">Name:</label><input name="name" type="text" /><br /><br />
<label for="email">Email:</label><input name="email" type="text" /><br /><br />
<label for="phone">Phone:</label><input name="phone" type="text" /><br /><br />
<label for="cmcenquiryform">Enquiry For:</label>

<select name="cmcenquiryform">
<option>Joining Courses</option>
<option>Franchisee</option>
<option>Corporate Training</option>
<option>Others</option>
</select><br /><br />
<label for="query">Query:</label><textarea name="query" cols="25" rows="5"></textarea><br /><br />

<input name="enquire" type="submit" value="Enquire Now!" class="submit"/><br /><br />

</form>

if you face any problem in code then reply your error here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.