Forum Moderators: coopster
<div class="form_box">
<div class="form_box-1">
<p>City</p>
<input class="form-1" type="text" name="city" id="city" value="<? echo $_SESSION['city']?>" />
</div>
<div class="form_box-1">
<p>Email</p>
<input class="form-1" type="text" name="email" id="email" value="<? echo $_SESSION['email']?>" />
</div>
<div class="form_box-1">
<p>How soon are you<br /> looking to buy?</p>
<select name="to_buy" id="to_buy" style="margin:6px;">
<option value="Immediately" <? echo ($_SESSION['to_buy']=="Immediately")?"selected=\"selected\"":""?>>Immediately</option>
<option value="30-90 days" <? echo ($_SESSION['to_buy']=="30-90 days")?"selected=\"selected\"":""?>>30-90 days</option>
<option value="3-6 months" <? echo ($_SESSION['to_buy']=="3-6 months")?"selected=\"selected\"":""?>>3-6 months</option>
<option value="6-12 months" <? echo ($_SESSION['to_buy']=="6-12 months")?"selected=\"selected\"":""?>>6-12 months</option>
</select>
</div>
<div class="form_box-1">
<input type="button" class="buton-1" value=" " onclick="callAjax()" />
</div> <?php include_once('header.php');?>
<div align="center">
<?php echo $message?>
<h2>Enter Contact Email Address</h2>
<form method="post" action="">
E-mail address: <input type="text" name="src_mail" />
<input type="submit" value="Sign Up" />
</form>
</div>
<?php include_once('footer.php'); ?> So you validate all your form inputs, and only if there are no errors do you execute a SQL insert. If that does not fail, you then run your mail() function.if(count($_POST)) {
$errors = array();
if(!isset($_POST['something_one']) || empty($_POST['something_one'])) {
$errors[] = 'Something one is not set.';
}
if(!isset($_POST['something_two']) || empty($_POST['something_two'])) {
$errors[] = 'Something two is not set.';
}
// Other validation here
// Other validation here
// Other validation here
if(!count($errors)) {
$sql = ''; // SQL INSERT statement
mysql_query($sql);
if(mysql_error()) {
$errors[] = 'An unexpected database error occured.';
} else {
// Build your mail variables here
if(mail($to, $subject, $message, $headers, $parameters)) {
echo 'Success!';
} else {
$errors[] = 'An un expected error occured.';
$sql = ''; // SQL DELETE statement
mysql_query($sql);
}
}
}
if($count = count($errors)) {
echo '<ul>'
for($i = 0; $i < $count; $i++) {
echo '<li>' . $errors[$i] . '</li>';
}
echo '</ul>';
}
}
and the constant contact API coding is :