Hello Everybody! I’m new to this forum and to the world of PHP. I have been given a project to create a web contact form with a dropdown box of recipients. I’ve created the html code and the PHP code; however, it doesn’t work. Also, PHP was just installed on my web server, so I’m not sure if it’s my code or server issues. As you can tell from my code, I’m more of a designer than a programmer. :/ ANY help would be GREATLY appreciated!
Thank you!
My HTML CODE:
[CODE]<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Sales Contact Form</title>
<style type=”text/css”>
.container {
font-family: Arial, Helvetica, sans-serif;
font-size: 18px;
font-weight: bolder;
width: 500px;
color: #000;
}
</style>
</head>
<body>
<div class=”container”>
<fieldset>
<legend>Contact Us</legend>
<form action=”contactFormSite/contact_us.php” method=”post” name=”contact” id=”contact_form”>
<table width=”498″ height=”362″ border=”0″ cellpadding=”9″>
<tr>
<td><label>Name</label></td>
<td><input name=”email_address” type=”text” class=”name” size=”40″/></td>
</tr>
<tr>
<td>
<label>Email Address</label></td>
<td><input name=”email_address” type=”text” class=”required email” size=”40″/></td>
</tr>
<tr>
<td> <label>Subject</label></td>
<td><select name=”subject”>
<option value=”Select one:” selected=”selected”>Select one:</option>
<option value=”recipient_5″>Cars</option>
<option value=”recipient_2″>Real Estate</option>
<option value=”recipient_4″>Equipment</option>
<option value=”recipient_3″>Events</option>
<option value=”Recipient_6″>Finance or Accounting </option>
<option value=”Recipient_7″>Website Related Matters</option>
<option value=”recipient_1″>Sales Manager</option>
</select></td>
</tr>
<tr>
<td align=”left” valign=”top”><label>Message</label></td>
<td><textarea name=”message” cols=”40″ rows=”15″ ></textarea></td>
</tr>
<tr>
<td>*</td>
<td><input type=”submit” value=”Submit Form” style=”font-family: ‘Arial’; font-size: 12px; letter-spacing: 1px” />
<input type=”reset” value=”Reset Form” style=”font-family: ‘Arial’; font-size: 12px; letter-spacing: 1px” /></td>
</tr>
</table>
</form>
</fieldset>
</div>
</body>
</html>
My PHP Code:
[CODE]<?php
$state = 1;
if(isset($_POST[‘name’])) {
// multiple recipients
$to = ”; // note the comma
// subject
$subject = $_POST[‘subject’];
// message
$message = ”
<html>
<head>
<title>”.$_POST[‘subject’].”</title>
</head>
<body>
<p>
Name: “.$_POST[‘name’].” <br />
Contact Number: “.$_POST[‘contact_number’].” <br />
Email: “.$_POST[’email_address’].” <br />
Enquiry: “.$_POST[‘message’].” <br />
</p>
</body>
</html>
“;
// To send HTML mail, the Content-type header must be set
$headers = ‘MIME-Version: 1.0’ . “rn”;
$headers .= ‘Content-type: text/html; charset=iso-8859-1’ . “rn”;
// Additional headers
$headers .= ‘To: recepient_1 <‘.$to.’>’ . “rn”;
$headers .= ‘From: recepient_1 <‘.$to.’>’ . “rn”;
$to = $recepient = [$_REQUEST[‘recepient’]];
‘recepient_1’ => ‘[email protected]’,
‘recepient_2’ => ‘[email protected]’,
‘recepient_3’ => ‘[email protected]’,
‘recepient_4’ => ‘[email protected]’,
‘recepient_5’ => ‘[email protected]’,
‘recepient_6’ => ‘[email protected]’,
‘recepient_7’ => ‘[email protected]’,
‘recepient_8’ => ‘[email protected]’
);
$my_email = $recepient[$_REQUEST[‘recepient’]];
// Mail it
mail($to, $subject, $message, $headers);
$state = 2;
}
?>