I’ve been beating my head on this for hours, and need some fresh eyes. Can someone please help:
I’ve got a form here:
http://www.cincocharities.org/events/golf/players.php
It’s validated with jquery, has a captcha image and get’s submitted to itself to process entries. Problem is if users get the captcha code wrong, they’re told to go back and enter the correct code. When the go back, all the form data they previously typed in is gone and they have to enter it all over again.
My code is as below, can someone point me in the right direction?!?! Please!
<?php
session_start();
include_once "../../config/config.php";
dbConnect($db_name);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Player Information for the 5th Annual Keller Williams Golf Classic at River Ridge Golf Club Benifiting Cinco Charities</title>
<meta name="description" content="Player Information for the 5th Annual Keller Williams Golf Classic at River Ridge Golf Club on April 19, 2010" />
<meta name="keywords" content="player, information, player information, keller williams, golf classic, golf, classic, tournament, charity tournament, charity, raise money, fundraiser, katy, texas, katy texas, katy area, housing, for, families" />
<meta name="author" content="Xenine Solutions" />
<meta name="copyright" content="Copyright <?php echo date("Y");?>." />
<meta name="rating" content="GENERAL" />
<meta name="revisit-after" content="5 Days" />
<meta name="robots" content="ALL" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="../../config/style.css" type="text/css" media="screen" />
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" media="all" href="../../config/iestyle.css" />
<![endif]-->
<!--[if IE 8]>
<link rel="stylesheet" type="text/css" media="all" href="../../config/ie8style.css" />
<![endif]-->
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" media="all" href="../../config/ie6style.css" />
<![endif]-->
<style type="text/css">
* { }
label { width: 10em; float: left; }
label.error { float: none; color: red; padding-left: .5em; vertical-align: top; }
p { clear: both; }
.submit { margin-left: 12em; }
em { font-weight: bold; padding-right: 1em; vertical-align: top; }
</style>
<script type="text/javascript" src="../../config/typeface-0.14.js"></script>
<script type="text/javascript" src="../../config/chunkfive.js"></script>
<script type="text/javascript" src="../../config/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="../../config/jquery.validate.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#myform").validate();
});
</script>
</head>
<body>
<div id="wrapper2">
<div id="topnav">
<a href="../../" title="Home">Home</a>
<a href="../../board.php" title="Who We Are">Who We Are</a>
<a href="../../whatwedo.php" title="What We Do">What We Do</a>
<a href="../../help.php" title="How You Can Help">How You Can Help</a>
<a href="../../news.php" title="News & Events" class="pager">News & Events</a>
<a href="../../media.php" title="Media">Media</a>
<a href="../../contactus.php" title="Contact Us">Contact Us</a>
</div>
<!--end #topnav-->
<!--start #topnav-sub-->
<div id="topnav-sub">
<a href="../../news.php" title="Latest News">Latest News</a>
<a href="../../events/golf" title="Golf Classic" class="pager">Golf Classic</a>
<a href="../../events/poker" title="Poker Tournament">Poker Tournament</a>
<a href="../../events/wine" title="Wine Tasting">Wine Tasting</a>
<a href="../../events/vision" title="Vision Event">Vision Event</a>
<a href="../../events/dinners" title="Night Outs">Night Outs</a>
</div>
<div id="container">
<div id="left-div">
<div class="featured">
<div class="featured-thumb-wrapper">
<img src="../../photos/player_banner.jpg" alt="Player Information" class="featured-thumb" width="570" height="300" />
</div>
<div style="clear: both;"></div>
<?php
if (isset($_POST["auth"])) {
if(($_SESSION["captcha"] == $_POST["code"]) && (!empty($_SESSION["captcha"])) ) {
// retrieve entered values
$contact = trim($_POST["contact"]);
$address = trim($_POST["address"]);
$city = trim($_POST["city"]);
$state = $_POST["state"];
$zip = $_POST["zip"];
$phone = trim($_POST["phone"]);
$email = trim($_POST["email"]);
$tpl = 0;
$player1 = trim($_POST["play1"]);
$handi1 = trim($_POST["hand1"]);
if ($player1 <> "") { $tpl = $tpl + 1; }
$player2 = trim($_POST["play2"]);
$handi2 = trim($_POST["hand2"]);
if ($player2 <> "") { $tpl = $tpl + 1; }
$player3 = trim($_POST["play3"]);
$handi3 = trim($_POST["hand3"]);
if ($player3 <> "") { $tpl = $tpl + 1; }
$player4 = trim($_POST["play4"]);
$handi4 = trim($_POST["hand4"]);
if ($player4 <> "") { $tpl = $tpl + 1; }
// assemble email message
include("../../config/class.phpmailer.php");
include("../../config/class.smtp.php"); // note, this is optional - gets called from main class if not already loaded
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port
$mail->Username = "website@cincocharities.org"; // GMAIL username
$mail->Password = "password99"; // GMAIL password
$mail->From = "website@cincocharities.org";
$mail->FromName = "Cinco Charities";
$mail->Subject = "New Golf Classic Player Registration";
$mail->Body = "<p>The following Player Registration was recently submitted on the Cinco Charities website:</p><p><strong>Name:</strong> $contact<br /> <strong>Address:</strong> $address<br /><strong>City, State, Zip:</strong> $city, $state, $zip<br /><strong>Phone:</strong> $phone<br /><strong>Email:</strong> $email<br /><strong>Players:</strong><br /><br /><strong>Player 1:</strong> $player1, $handi1<br /><strong>Player 2:</strong> $player2, $handi2<br /><strong>Player 3:</strong> $player3, $handi3<br /><strong>Player 4:</strong> $player4, $handi4</p><p>Please respond to this visitor as soon as possible.<br />Cinco Charities Website Daemon</p>";
$mail->AltBody = "The following Player Registration was recently submitted on the Cinco Charities website:/nName: $contact/nAddress: $address/nCity, State, Zip: $city, $state, $zip/nPhone: $phone/nEmail: $email/n/nPlayers:/n/n$player1 - $handi1/n$player2 - $handi2/n$player3 - $handi3/$player4 - $handi4/n/nPlease respond to this visitor as soon as possible./nCinco Charities Website Daemon";
$mail->WordWrap = 50; // set word wrap
$mail->SetLanguage("en", "config/");
$mail->AddReplyTo($email,$name);
$mail->AddAddress("brian@cincocharities.org","Cinco Charities");
$mail->AddAddress("chris@cincocharities.org","Cinco Charities");
$mail->IsHTML(true); // send as HTML
if(!$mail->Send()) {
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
} else {
?>
<div class="h1class typeface-js" style="font-family: ChunkFive">
Thank You for Registering to Play!
</div>
<div class="h4class typeface-js" style="font-family: ChunkFive">
April 19, 2010 at 12 Noon
</div>
<div style="clear: both;"></div>
<form action="https://checkout.google.com/cws/v2/Merchant/checkoutForm" id="BB_BuyButtonForm" method="post" name="BB_BuyButtonForm" target="_blank">
<p>
Your registration has been received. A summary of the information you supplied is listed below. You should receive a confirmation email at the address you supplied shortly. You can pay for your
registration online now through <span style="color: blue">G</span><span style="color: red">o</span><span style="color: yellow">o</span><span style="color: blue">g</span><span style="color: green">l</span>
<span style="color: red">e</span> <span style="color: blue">Checkout</span> below or contact us at 281.220.2188 to make arrangements.
</p>
<table width="585" cellpadding="2" cellspacing="2" border="0" style="border: 1px solid #CCCCCC">
<tr>
<td colspan="2" style="background-color: #F7F3F7; border-bottom: 1px solid #CCCCCC; color: #1A1A1A; font-weight: bold; text-align: left"> Registrant Details:</td>
</tr>
<tr>
<td>Contact Name:</td>
<td><?php echo $contact;?></td>
</tr>
<tr>
<td>Mailing Address:</td>
<td><?php echo $address;?></td>
</tr>
<tr>
<td>City, State, Zip:</td>
<td><?php echo $city.", ".$state." ".$zip;?></td>
</tr>
<tr>
<td>Phone:</td>
<td><?php echo $phone;?></td>
</tr>
<tr>
<td>Email:</td>
<td><?php echo $email;?></td>
</tr>
</table>
<br />
<table width="585" cellpadding="2" cellspacing="2" border="0" style="border: 1px solid #CCCCCC">
<tr>
<td colspan="3" style="background-color: #F7F3F7; border-bottom: 1px solid #CCCCCC; color: #1A1A1A; font-weight: bold; text-align: left"> Team Details:</td>
</tr>
<tr>
<td style="text-align: center; width: 10%">1.</td>
<td style="text-align: left; width: 80%"><?php echo $player1;?></td>
<td style="text-align: center; width: 10%"><?php echo $handi1;?></td>
</tr>
<tr>
<td style="text-align: center">2.</td>
<td style="text-align: left"><?php echo $player2;?></td>
<td style="text-align: center"><?php echo $handi2;?></td>
</tr>
<tr>
<td style="text-align: center">3.</td>
<td style="text-align: left"><?php echo $player3;?></td>
<td style="text-align: center"><?php echo $handi3;?></td>
</tr>
<tr>
<td style="text-align: center">4.</td>
<td style="text-align: left"><?php echo $player4;?></td>
<td style="text-align: center"><?php echo $handi4;?></td>
</tr>
</table>
<br />
<table width="585" cellpadding="2" cellspacing="2" border="0" style="border: 1px solid #CCCCCC">
<tr>
<td colspan="3" style="background-color: #CC0000; border-bottom: 1px solid #CCCCCC; color: #FFFFFF; font-weight: bold; text-align: left"> Cost Details:</td>
</tr>
<tr>
<td style="text-align: center; width: 10%"><?php echo $tpl;?></td>
<td style="text-align: left; width: 80%">Golfers @ $130.00 each</td>
<td style="text-align: right; width: 10%">$<?php if ($tpl > 0) { echo number_format($tpl * 130,2); }?></td>
</tr>
<tr>
<td style="text-align: center; border-bottom: 1px solid #CCCCCC;"><?php echo $tpl;?></td>
<td style="text-align: left; border-bottom: 1px solid #CCCCCC;">Convenience Fees @ $4.20 each</td>
<td style="text-align: right; border-bottom: 1px solid #CCCCCC;">$<?php if ($tpl > 0) { echo number_format($tpl * 4.20,2); }?></td>
</tr>
<tr>
<td style="text-align: center"> </td>
<td style="text-align: left"><strong>Total Cost for this Team:</strong></td>
<td style="text-align: right"><strong>$<?php if ($tpl > 0) { echo number_format($tpl * 134.20,2); }?></strong></td>
</tr>
</table>
<br />
<div class="h2class typeface-js" style="font-family: ChunkFive">
Pay Now Online with Google Checkout!
</div>
<input name="item_selection_1" type="hidden" value="1"/>
<input name="item_option_name_1" type="hidden" value="Registration"/>
<input name="item_option_price_1" type="hidden" value="134.20"/>
<input name="item_option_description_1" type="hidden" value="Player Registrations for <?php echo $tpl;?>"/>
<input name="item_option_quantity_1" type="hidden" value="<?php echo $tpl;?>"/>
<input name="item_option_currency_1" type="hidden" value="USD"/>
<input alt="" src="../../images/buy.gif" type="image" style="border: none; background: none;"/>
</form>
<p> </p>
<?php
}
unset($_SESSION['security_code']);
} else {
echo "<p>The security code you entered does match code provided. In order for this form to work, your code must enter exactly the code provided.</p>";
echo "<p>Please hit the back button in your browser, and try again!</p>";
}
} else {
?>
<div class="h1class typeface-js" style="font-family: ChunkFive">
Be a Player in Our Tournament
</div>
<div class="h4class typeface-js" style="font-family: ChunkFive">
April 19, 2010 at 12 Noon
</div>
<div style="clear: both;"></div>
<p>
Keller Williams Realty Katy @ Cinco Ranch is proud to announce our 5th Annual Keller Williams Golf Classic to be held on April 19, 2010 at River Ridge Golf Club.
Over the last four years, we have raised over $80,000 for Cinco Charities thanks to the overwhelming support of people like you.
</p>
<p>
Cinco Charities, Inc. is the Non-Profit Organization created and run by our Keller Williams Realty Katy @ Cinco Ranch associates. We believe in doing more than
selling real estate. Leaving a legacy in our community is a passion we share, continuing our dream to provide temporary housing in our community with a warm,
safe environment for individuals and their families who are hospitalized or receiving treatment for serious medical conditions.
</p>
<p>
How can you help? You, your friends and family can come out and enjoy of great day of fun, food, drink and Golf in our 5th Annual Golf Classic! The last four
years, we've played a full field at River Ridge Golf Course in West Houston. Goodie bags, lunch, golf, cart, and dinner is provided with your registration. And
keep in mind, your donations may be tax deductible to the extent provided by law as defined in Section 501 (c) (3) of the IRS Code.
</p>
<p>
To participate as a player or team, please contact Chris Hiller at Keller Williams Realty Katy @ Cinco Ranch - 281-220-2100. For your convenience, you may also
register online and pay with a credit card. (Service fees may apply).
</p>
<p>
We appreciate your continued support and invite you to attend this day of fun and kinship.
</p>
<p> </p>
<p> </p>
<?php
}
?>
</div><div style="clear: both;"></div>
</div>
<div id="sidebar">
<div class="sidebar-box">
<span class="sidebar-box-title">Event Details</span>
<div style="clear: both"></div>
<ul class="news">
<li><a href="./default.php" title="Classic Homepage">Classic Homepage</a></li>
<li><a href="./details.php" title="Classic Details">Classic Details</a></li>
<li><a href="./venue.php" title="Tournament Venue">The Venue</a></li>
<li><a class="current" href="./players.php" title="For Players">For Players</a></li>
<li><a href="./sponsors.php" title="For Sponsors">For Sponsors</a></li>
<li><a href="./gallery.php" title="Photo Gallery">Photo Gallery</a></li>
</ul>
</div>
<div class="sidebar-box">
<span class="sidebar-box-title2">Golfer Registration - $130pp + SC</span>
<div style="clear: both;"></div>
<p>
To register to play in our tournament, simply complete the form below to register. Once registration is complete, you'll have the option to pay online.
</p>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post" id="myform">
<input type="hidden" name="auth" value="auth" />
<div>
<label for="contact">Name:</label>
<input type="text" name="contact" class="treehope required" />
</div>
<div>
<label for="address">Address:</label>
<input type="text" name="address" class="treehope required" />
</div>
<div>
<label for="city">City:</label>
<input type="text" name="city" class="treehope required" />
</div>
<div>
<label for="state">State:</label>
<select name="state" id="state" class="treehope required">
<option selected>Select a State</option>
<option value="Alabama">Alabama </option>
<option value="Alaska">Alaska </option>
<option value="Arizona">Arizona </option>
<option value="Arkansas">Arkansas </option>
<option value="California">California </option>
<option value="Colorado">Colorado </option>
<option value="Connecticut">Connecticut </option>
<option value="Delaware">Delaware </option>
<option value="D.C.">D.C.</option>
<option value="Florida">Florida </option>
<option value="Georgia">Georgia </option>
<option value="Hawaii">Hawaii </option>
<option value="Idaho">Idaho</option>
<option value="Illinois">Illinois </option>
<option value="Indiana">Indiana </option>
<option value="Iowa">Iowa </option>
<option value="Kansas">Kansas </option>
<option value="Kentucky">Kentucky </option>
<option value="Louisiana">Louisiana </option>
<option value="Maine">Maine </option>
<option value="Maryland">Maryland </option>
<option value="Massachusetts">Massachusetts </option>
<option value="Michigan">Michigan </option>
<option value="Minnesota">Minnesota </option>
<option value="Mississippi">Mississippi </option>
<option value="Missouri">Missouri </option>
<option value="Montana">Montana </option>
<option value="Nebraska">Nebraska </option>
<option value="Nevada">Nevada </option>
<option value="New Hampshire">New Hampshire </option>
<option value="New Jersey">New Jersey </option>
<option value="New Mexico">New Mexico </option>
<option value="New York">New York </option>
<option value="North Carolina">North Carolina </option>
<option value="North Dakota">North Dakota </option>
<option value="Ohio">Ohio </option>
<option value="Oklahoma">Oklahoma </option>
<option value="Oregon">Oregon </option>
<option value="Pennsylvania">Pennsylvania </option>
<option value="Rhode Island">Rhode Island </option>
<option value="South Carolina">South Carolina </option>
<option value="South Dakota">South Dakota </option>
<option value="Tennessee">Tennessee </option>
<option value="Texas" selected="selected">Texas </option>
<option value="Utah">Utah </option>
<option value="Vermont">Vermont </option>
<option value="Virginia">Virginia </option>
<option value="Washington">Washington </option>
<option value="West Virginia">West Virginia </option>
<option value="Wisconsin">Wisconsin </option>
<option value="Wyoming">Wyoming </option>
</select>
</div>
<div>
<label for="zip">Zip:</label>
<input type="text" name="zip" class="short required" />
</div>
<div>
<label for="phone">Phone:</label>
<input type="text" name="phone" class="treehope required phoneUS" value="xxx-xxx-xxxx" onfocus="this.value=''" />
</div>
<div>
<label for="email">Email:</label>
<input type="text" name="email" class="treehope required email" />
</div>
<p>
For each player in your group, please enter a player name and handicap in the form below.
</p>
<div>
<label for="email">Player 1:</label>
<input type="text" name="play1" class="play" />
<input type="text" name="hand1" class="teeny" />
</div>
<div>
<label for="email">Player 2:</label>
<input type="text" name="play2" class="play" />
<input type="text" name="hand2" class="teeny" />
</div>
<div>
<label for="email">Player 3:</label>
<input type="text" name="play3" class="play" />
<input type="text" name="hand3" class="teeny" />
</div>
<div>
<label for="email">Player 4:</label>
<input type="text" name="play4" class="play" />
<input type="text" name="hand4" class="teeny" />
</div>
<div>
<label for="confirm">Code:</label>
<input type="text" name="code" class="short required" /> <img src="../../config/captcha2.php" />
</div>
<div style="padding: 20px 0px 0px 0px; text-align: left">
<button type="submit" class="positive"> Submit</button>
<button type="reset" class="negative"> Reset</button>
</div>
</form>
</div>
</div>
</div>
<?php include_once "../i_footer.php";?>
<?php include_once "../../i_google.php"; ?>
</body>
</html>