Jump to content

Contact Form Not Working


hansman

Recommended Posts

Data passes through as a 1 or 0 from the previous page, 1 is supposed to go to [email protected], while 0 goes to [email protected]. For some reason, all of the email, no matter what the selection goes to [email protected].

 

Thanks in advance.

 

<?
$yes="[email protected]"; // $yes="[email protected]";
$no="[email protected]"; // $no="[email protected]";
?>
<?php
$vname=$_POST["name"];
$vemail=$_POST["email"];
$vphone=$_POST["phone"];
$vsubject=$_POST["subject"];
$vbody=$_POST["body"];
if($_POST['RadioGroup']==1)

{
$to=$yes;
}
else
{
$to=$no;
}

/* recipients */
//$to="[email protected]";
/* subject */
$subject = $vname;
/* message */
$message = "
<html>
<head>
<title>Contact</title>
</head>
<body>
<p>Contact</p>
<table  border=\"0\"  align=\"center\" cellpadding=\"0\" cellspacing=\"10\">
<tr>
<td>name:</td><td>".$vname."</td>
</tr>
<tr>
<td>Phone: </td><td>".$vphone."</td>
</tr>
<tr>
<td>Email: </td><td>".$vemail."</td>
</tr>
<tr>
<td>Location: </td><td>".$vsubject."</td>
</tr>
<tr>
<td>Message: </td><td>".$vbody."</td>
</tr>
</table>
</body>
</html>
"; 
/* To send HTML mail, you can set the Content-type header. */
$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=utf-8\r\n";

/* additional headers */
$headers .= "To: ".$to."\r\n";
$headers .= "From: ".$vemail."\r\n";

/* and now mail it */
mail($to, $subject, $message, $headers);
echo "<h2>Thank you for contacting us! We will have a representative get back to you shortly.</h2>";
?>

 

Here is what the form look like on the previous page

<label  for="contact_bs">Are you currently an active program client?</label><br/>
  <input type="radio" value="1" name="RadioGroup" checked="checked">Yes<input type="radio" value="0" name="RadioGroup">No
  <br />
</p>
<form onsubmit="return validateForm(this);" class="form-validate"  id="contact" name="contact" method="post" action="contact_action.php">
<label class="required" for="contact_name">Name</label><br/>
<input type="text" class="inputbox" value="" size="30" id="contact_name" name="name"/><br/>
<label class="required" for="contact_phone">Phone</label><br/>
<input type="text" class="inputbox" value="" size="30" id="contact_phone" name="phone"/><br/>
<label class="required" for="contact_email">E-mail address</label><br/>
<input type="text" class="inputbox" value="" size="30" id="contact_email" name="email"/><br/>
<label class="required" for="contact_location">City / State</label><br/>
<input type="text" class="inputbox" value="" size="30" id="contact_subject" name="subject"/><br/>
<label class="required" for="contact_text">Enter your Message</label><br/>
<textarea class="inputbox" id="contact_text" name="body" rows="10" cols="50"/></textarea><br/>
<input type="submit" value="Send" class="contact-button" name="submit"/>
<br/>
</form>

Link to comment
https://forums.phpfreaks.com/topic/198460-contact-form-not-working/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.