Skipjackrick Posted October 21, 2008 Share Posted October 21, 2008 I've been racking my brain trying to figure out why my simple form won't post. It just continues to bring me back to the initial page. I need a pair of fresh eyes. Can anybody do a quick scan and tell me what might be wrong? Anglers start at 101 http://www.ectackle.com/Sharkathon/catchlog.php <?php include 'auth.inc.php'; #################################################################### ################ DATABASE CONFIGURE ############################## #################################################################### $hostname = "localhost"; $db_user = "********"; $db_password = "*********"; $db_table = "catch_log"; # STOP HERE #################################################################### # THIS CODE IS USED TO CONNECT TO THE MYSQL DATABASE $db = mysql_connect($hostname, $db_user, $db_password); mysql_select_db ("********") or die (mysql_error()); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <link rel="SHORTCUT ICON" href="layout/favicon.ico" /> <link rel="stylesheet" href="layout/layout.css" type="text/css" /> <title>Sharkathon Catch Log Database</title></head> <body> <div id="wrap"> <!--header --> <div id="header"> <h1 id="logo-text"></h1> </div> <?php if($_GET['user_id']){ $error = null; if($result = mysql_query(sprintf("SELECT * FROM user_info WHERE user_id = '%s' LIMIT 1",mysql_real_escape_string($_GET['user_id'])))){ $c = mysql_fetch_assoc($result); if(!$c){ $error = "Angler not found"; } }else{ $error = "Query Failed"; } } ?> <!-- menu --> <div id="content-wrap"> <div id="main"> <form method="GET" action=""> Lookup By Contestant ID: <input type="text" name="user_id" /> <input type="submit" value="Lookup" /><br /> <?php if($error) echo '<p style="color:red;">Error: '.$error.'</p>'; ?> </form> <p> </p> <?php if (isset($_POST['Submit'])) { $entry_id = $_POST['entry_id']; $user_id = $_POST['user_id']; $name = $_POST['name']; $shark = $_POST['shark']; $red = $_POST['red']; $trout = $_POST['trout']; $kids = $_POST['kids']; $ladies = $_POST['ladies']; $tarpon = $_POST['tarpon']; $date = $_POST['date']; $bait = $_POST['bait']; $species = $_POST['species']; $length = $_POST['length']; $fork = $_POST['fork']; $location = $_POST['location']; $time = $_POST['time']; # THIS CODE TELLS MYSQL TO INSERT THE DATA FROM THE FORM INTO YOUR MYSQL TABLE $sql = "INSERT INTO catch_log(entry_id, user_id, name, shark, red, trout, kids, ladies, tarpon, date, bait, species, length, fork, location, time) values ('$entry_id', '$user_id', '$name', '$shark', '$red', '$trout', '$kids', '$ladies', '$tarpon', '$date', '$bait', '$species', '$length', '$fork', '$location', '$time')"; if($result = mysql_query($sql ,$db)) { echo "<br>"; echo "Thank you, Your information has been entered into the database."; echo "<br>"; echo "<br>"; echo "<a href='http://www.ectackle.com/Sharkathon/catchlog.php'>"; echo "Click here to make another submission"; echo "</a>"; echo "<br>"; echo "<br>"; echo "<br>"; echo "<br>"; echo "<br>"; echo "<br>"; echo "<br>"; } else { echo "ERROR: ".mysql_error(); } } else { ?> <form action="" enctype="multipart/form-data" name="form" id="form" method="POST"> <input type="hidden" name="entry_id" value="NULL"> <div align="center">Name: <input name="name" type="text" value="<?php echo htmlspecialchars($c['name']); ?>" /> Shark: <input name="shark" type="text" value="<?php echo htmlspecialchars($c['shark']); ?>" size="1" maxlength="2" /> Redfish: <input name="red" type="text" value="<?php echo htmlspecialchars($c['red']); ?>" size="1" maxlength="2" /> Trout: <input name="trout" type="text" value="<?php echo htmlspecialchars($c['trout']); ?>" size="1" maxlength="2" /> Kids: <input name="kids" type="text" value="<?php echo htmlspecialchars($c['kids']); ?>" size="1" maxlength="2" /> Ladies: <input name="ladies" type="text" value="<?php echo htmlspecialchars($c['ladies']); ?>" size="1" maxlength="2" /> Tarpon: <input name="tarpon" type="text" value="<?php echo htmlspecialchars($c['tarpon']); ?>" size="1" maxlength="2" /> </div> <p> </p> <div align="center"> <p>Date: <select name="date" id="date" > <option value="0">Select a Date</option> <option value="100308">10/03/2008</option> <option value="100408">10/04/2008</option> <option value="100508">10/05/2008</option> </select> Bait: <select name="selection" id="selection" > <option value="0">Select a Bait</option> <option value="Ladyfish">Ladyfish</option> <option value="Stingray">Stingray</option> <option value="Whiting">Whiting</option> <option value="Mullet">Mullet</option> <option value="Sand Trout">Sand Trout</option> <option value="Sheepshead">Sheepshead</option> </select> Species: <select name="species" id="species" > <option value="0">Select a Species</option> <option value="Blacktip">Blacktip</option> <option value="Bull">Bull</option> <option value="Sharpnose">Sharpnose</option> <option value="Trout">Trout</option> <option value="Redfish">Redifsh</option> <option value="Tiger">Tiger</option> <option value="Tarpon">Tarpon</option> <option value="Ladyfish">Ladyfish</option> <option value="Stingray">Stingray</option> <option value="Whiting">Whiting</option> <option value="Mullet">Mullet</option> <option value="Sand Trout">Sand Trout</option> <option value="Sheepshead">Sheepshead</option> </select> </p> <p><br /> Length: <input type="text" id="length" size="4" maxlength="5" /> Re-Verify Length: <input type="text" id="length2" size="4" maxlength="5" /> Fork: <input type="text" id="fork" size="4" maxlength="5" /> Location: <input type="text" id="location" size="4" maxlength="5" /> Time: <input type="text" id="time" size="4" maxlength="5" /> <br> <br> <br> <input type="Submit" value="Submit" /> <br /> </p> </div> </form> <?php } ?> </div> <!-- content-wrap ends here --> </div> <!--footer starts here--> <div id="footer"> <p> © 2009 <strong>Sharkathon</strong>| Design by: sharkathon.com</p> </div> <!-- wrap ends here --> </div> <div style="font-size: 0.8em; text-align: center; margin-top: 1.0em; margin-bottom: 1.0em;"></div> </body> </html> Quote Link to comment Share on other sites More sharing options...
discomatt Posted October 21, 2008 Share Posted October 21, 2008 With a blank action, the form will post to the originating page. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 21, 2008 Share Posted October 21, 2008 Your submit input field has no name="..." parameter so $_POST['Submit'] will never be set. Quote Link to comment Share on other sites More sharing options...
Skipjackrick Posted October 21, 2008 Author Share Posted October 21, 2008 Your submit input field has no name="..." parameter so $_POST['Submit'] will never be set. Yes! Thanks, wow I thought I was just going to have to start over. Can't learn until you make mistakes I guess. Do you guys have some sort of code check program? How can you spot stuff like that? Or is it just plain experience? Quote Link to comment Share on other sites More sharing options...
revraz Posted October 21, 2008 Share Posted October 21, 2008 Looking for the obvious first. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 21, 2008 Share Posted October 21, 2008 From my signature - Debugging step #1: To get past the garbage-out=garbage-in stage in your code, you must check that the inputs to your code are what you expect. Your code is expecting $_POST['Submit'] to be set before it will do anything. I simply looked back to where that value is produced. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.