Jump to content

Selection box mail problem


richard_PHP

Recommended Posts

Hello all,

 

I have a contact form which has a drop-down-menu (the reason why a user is using the form). I am wanting the option which has been selected to appear in the PHP scripted email as the subject. I am just sat here staring at the code and getting nowhere with it. Could anyone help me?

 

HTML form

<form name="contact_form" method="post" action="mail.php" onsubmit="return validate_form();">
<p>Full Name <em>(required)</em>:<br />
<input class="tb-focus" type="text" name="name" id="name" size="40" value="" /></p>
<p>Reason for Contact:<br />
<select class="select">
<option value="CV">CV Request</option>
<option value="enquiry">General Enquiry</option>
<option value="request">Request for Audition</option>
</select>
<p>Email Address <em>(required)</em>:<br />
<input class="tb-focus" type="text" name="email" id="email" size="40" value="" /></p>
<p>Agency Name <em>(if applicable)</em>:<br />
<input class="tb-focus" type="text" name="business" id="business" size="40" value="" /></p>
<p>Contact Number <em>(required)</em>:<br />
<input class="tb-focus" type="text" name="number" id="number" size="40" value="" /></p>
<p>Message <em>(required)</em>:<br />
<textarea class="tb-focus" name="message" id="message" rows="6" cols="40"></textarea></p>
<p><input class="button" type="submit" value="Submit Form" /></p>
</form>

 

PHP email POST:

<?php
// Assign the posted values as variables to use later
$name = $_POST['name'];
$email = $_POST['email'];
$reason = $_POST['sdsdsd'];
$business = $_POST['business'];
$number = $_POST['number'];
$message = $_POST['message'];
$to = "*********";
$subject = "Email Contact Form - " . $_POST[name];
$message = "Filled out contact form on portfolio website.\n \n Full Name: " . $_POST[name] . "\n Email: " . $_POST[email] . "\n Business Name: " . $_POST[business] . "\n Contact Number: " . $_POST[number] . "\n Message: " . $_POST[message];

//leave the next 2 lines alone
$headers .= "MIME-Version: 1.0rn";
$headers .= "Content-Type: text/html; charset=ISO-8859-1rn"; 
if (empty($name) || empty($email) || empty($number) || empty($message)) {
echo "<p>You appear to not have filled in the necessary fields.</p>";
echo "<p>Please click <a href='contact.html'>here</a> to re-enter your information.</p>";
}
elseif(!mail($to, $subject, $message, $headers)){
echo "Sorry, there has been an error! Please try sending your message again. Click <a href='contact.htm'>here</a> to start again.";
} 
else {
echo "Thank you for taking the time to fill out the contact form. I will get back to you as soon as I can.";
}
?>

 

I have absolutely no idea where to start with this.

 

Thanks in advance for the help :D

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.