I give up. I've probably been messing with this around 5 hours now and am getting no where. This is the last 'complicated' feature i THINK i need on this site, but, as far as Ive come (and even completed the last form) i cant get this to make a second 'label' for reporting errors.
this code i have works PERFECT. send1 is checking a form and captcha and sending if everything is good.
send2 checks email1 and email2, makes sure they match, makes sure the captcha2 text box is correct and if so, sends it. i got this to work perfectly but if theres an error, send2 sends its error to the same place as send1. i just need 'send2' to send its error to a separate label, and how to call that label.
right now both errors are sending to this label, whereever i put this the follow code:
thanks in advance im so lost. i know NO php btw. just learning it trying to get this function going.
and i need to make a 2nd one of those, for 'send2' to send its errors to.PHP Code:<font color="red"><b><?php
if (isset($errors)) {
foreach ($errors as $error) {
echo("<p>$error<p>\n");
}
}
?></font></b>
full code:
PLUS!!!!PHP Code:<?php
if ($_POST['send']) {
$errors = array();
if ($_POST['captcha'] != $_SESSION['captchacode']) {
$errors[] = "You didn't enter the correct letters!";
}
if (empty($_POST['email'])) {
$errors[] = "Please enter an e-mail address";
}
else if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['email']))
{
$errors[] = 'Please enter a valid e-mail address';
}
if (!count($errors)) {
// IMPORTANT: If you don't call this the
// user will keep getting the SAME code!
captchaDone();
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
$phone = $_POST['phone'];
$optional = $_POST['callback'];
$cs = $_POST['cs'];
$email1 = $_POST['email1'];
$email2 = $_POST['email2'];
$body = "Name: $name_field, Email: $email_field, Phone: $phone, Location: $cs, Call Them! $optional, Message: $message";
mail($myaddress, 'Contact Form Submission', $body);
// Notice we can shift in and out of "HTML mode"
// to display some HTML only when the
// user passes the test
?>
<html>
<head>
<title>Message Sent</title>
</head>
<body>
<h1>Message Sent</h1>
Thank you for using our handy contact form.
<p>
<!-- Generate a link back to ourselves -->
<a href="<?php echo $SERVER['SCRIPT_URL']?>">Contact Us Again</a>
</body>
</html>
<?php
// Exit now to prevent the original form from
// appearing again
exit(0);
}
}
?>
<?php
if ($_POST['send2']) {
$errors = array();
if ($_POST['captcha2'] != $_SESSION['captchacode']) {
$errors[] = "You didn't enter the correct letters22222!";
}
if ($_POST['email1'] != $_POST['email2']) {
$errors[] = "The two emails do not match!!!!!!!!!!!!!!";
}
if (!count($errors)) {
// IMPORTANT: If you don't call this the
// user will keep getting the SAME code!
captchaDone();
$message = $_POST['email2'];
$body = "$message";
mail($myaddress, 'Contact Form Submission', $body);
// Notice we can shift in and out of "HTML mode"
// to display some HTML only when the
// user passes the test
?>
<html>
<head>
<title>Message Sent</title>
</head>
<body>
<h1>Message Sent</h1>
Thank you for using our handy contact form.
<p>
<!-- Generate a link back to ourselves -->
<a href="<?php echo $SERVER['SCRIPT_URL']?>">Contact Us Again</a>
</body>
</html>
<?php
// Exit now to prevent the original form from
// appearing again
exit(0);
}
}
?>
PHP Code:<form method="POST" action="<?php echo $SERVER['SCRIPT_URL']?>">
</tr>
<tr>
<td valign="top">
<label for="name">Name:</label>
</td>
<td valign="top">
<input type="text" name="email1" id="email1" MAXLENGTH=25 value="<?php if (!empty($_POST['email1'])) { echo $_POST['email1']; } ?>" />
</td>
</tr>
<tr>
<td valign="top">
<label for="phone">Phone:</label>
</td>
<td valign="top">
<input type="text" name="email2" id="email2" MAXLENGTH=12 value="<?php if (!empty($_POST['email2'])) { echo $_POST['email2']; } ?>" />
</td>
</tr><br><br>
<td valign="top"><input name="captcha" size="8"/>
</td>
</tr><tr>
<td valign="top"><span class="class2">
<label for="Message"><a href="<?php echo captchaWavUrl()?>">Listen To This</a> / <a href="javascript:location.reload(true);">Refresh</a></label></span>
</td>
</tr>
<tr>
<td colspan="2" style="text-align:center">
<img style="vertical-align: middle" src="<?php echo captchaImgUrl()?>">
<input type="submit" name="send2" value="Submit"/>
<font color="red"><b><?php
if (isset($errors)) {
foreach ($errors as $error) {
echo("<p>$error<p>\n");
}
}
?></font></b>
</td>
</tr>
</table>
</form>



Reply With Quote


Bookmarks