|
Hi... I'm new to this...
I need to get a form based on $_POST TO $_GET... I get a 405 error with $_POST and with $_GET nothing happens..
The code is
contact.html
<form action="script.php" method="get">
<table width="901" align=center bordercolor="#FFFFFF" bgcolor=#FFFFFF>
<tr>
<td colspan=2><div align="center" class="style31 style18">
<p class="style19">Contact Form</p>
<p> </p>
</div></td>
</tr>
<tr>
<td><span class="style16"><font color=red>*</font> Person:</span></td>
<td><span class="style16">
<select name="sendto">
<option value=" ">Haman </option>
<option value=" ">Liz </option>
<option value=" ">Kristen </option>
</select>
</span></td>
</tr>
<tr><td><span class="style16"><font color=red>*</font> Name:</span></td>
<td><input name="Name" size=25></td>
</tr>
<tr><td><span class="style16"><font color=red>*</font> Email:</span></td>
<td><input name="Email" size=25></td>
</tr>
<tr>
<td><span class="style17 style33"><strong>Company:</strong></span></td>
<td><input name="Company" size=25></td>
</tr>
<tr>
<td><span class="style17 style33"><strong>Phone:</strong></span></td>
<td><input name="Phone" size=25></td>
</tr>
<tr><td><span class="style17 style33"><strong>Subscribe to<br>
mailing list:</strong></span></td>
<td><span class="style16">
<input type="radio" name="list" value="No">
No Thanks<br>
<input type="radio" name="list" value="Yes" checked>
Yes, keep me informed<br>
</span></td>
</tr>
<tr>
<td colspan=2><span class="style16"><font color=red>*</font> Message:</span></td>
</tr>
<tr>
<td colspan=2 align=left><span class="style17">
<textarea name="Message" rows=5 cols=35></textarea>
</span></td>
</tr>
<tr><td colspan=2 align=center><input type="submit" name="send" value="Submit"></td></tr>
<tr><td colspan=2 align=center><small>A <font color=red>*</font> indicates a field is required</small></td></tr>
</table>
</form>
script.php
<?php
$to = $_GET['sendto'] ;
$from = $_GET['Email'] ;
$name = $_GET['Name'] ;
$headers = "From: $from";
$subject = "Contact Form";
$message = $_GET['Message'] ;
$fields = array();
$fields{"Company"} = "Company";
$fields{"Email"} = "Email";
$fields{"Phone"} = "Phone";
$fields{"list"} = "Mailing List";
$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_GET[$a]); }
$headers2 = "From: ";
$subject2 = "Thank you for contacting us";
$autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our website at www.oursite.com";
if($message == '') {print "You have not entered the message, please go back and try again";}
else {
if($to == '') {print "You have not entered the contact person, please go back and try again";}
else {
if($from == '') {print "You have not entered an email, please go back and try again";}
else {
if($name == '') {print "You have not entered a name, please go back and try again";}
else {
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
if($send)
{header( "Location: thanku.html" );}
else
{print "We encountered an error sending your mail."; }
}
}
}
}
?>
tHANK you
|