brownshoe Posted October 20, 2008 Share Posted October 20, 2008 I'm working on some scripts that get data from HTML forms via the "post" method. The scripts take the post data and use it to do various basic SQL statements. (duh?) However, I'm having a problem with them: When I click "submit" on the form, the script on the next page behaves as if it is receiving no post data. If I leave it alone for 30 seconds, then hit "refresh" on my browser (and resend post data), it finds the post data and works just like I wanted it to in the first place. What's going on here, and what's the way around it? Link to comment https://forums.phpfreaks.com/topic/129175-30-second-rule-for-post-data/ Share on other sites More sharing options...
redarrow Posted October 20, 2008 Share Posted October 20, 2008 post ur code please magic cristall ball gon to bed........... Link to comment https://forums.phpfreaks.com/topic/129175-30-second-rule-for-post-data/#findComment-669693 Share on other sites More sharing options...
brownshoe Posted October 20, 2008 Author Share Posted October 20, 2008 Here's a sample of the script that handles the post data: //assign post information $pilot=$_POST[PilotID]; $AircraftID=$_POST[AircraftID]; $registration=$_POST[registration]; //get info $query="SELECT `UserID`, `first_name`, `last_name` from `users` WHERE `UserID`='$pilot'"; $result=mysql_query($query); $row=mysql_fetch_array($result); $firstname=$row["first_name"]; $lastname=$row["last_name"]; //remove row from authorized_pilots $drop_query="DELETE FROM `authorized_pilots` WHERE `PilotID`='$pilot' AND `AircraftID`='$AircraftID' LIMIT 1"; $drop_result=mysql_query($drop_query); //echo success message and link back to homepage echo "<p align=\"center\">$firstname $lastname is no longer authorized to fly $registration.<br> <a href=\"pilothome.php\">Back to Pilot Homepage</a></p>"; This is the form that sends the information: echo "<td> <form action=\"drop_pilot.php\" method=\"post\"> <input type=\"hidden\" name=\"PilotID\" value=$PilotID> <input type=\"hidden\" name=\"AircraftID\" value=$AircraftID> <input type=\"hidden\" name=\"registration\" value=$registration> <input type=\"submit\" value=\"Remove\"></form></td>"; echo "</tr>"; Link to comment https://forums.phpfreaks.com/topic/129175-30-second-rule-for-post-data/#findComment-669699 Share on other sites More sharing options...
FForce2195 Posted October 20, 2008 Share Posted October 20, 2008 Change <form action=\"drop_pilot.php\" method=\"post\"> into <form action="drop_pilot.php" method="post"> . And you may want to remove all backslashes. Link to comment https://forums.phpfreaks.com/topic/129175-30-second-rule-for-post-data/#findComment-669701 Share on other sites More sharing options...
Bendude14 Posted October 20, 2008 Share Posted October 20, 2008 No dont remove your backslashes there escaping the Quotation marks. Where abouts are the vars set for your input values? value=$PilotID value=$AircraftID value=$registration Link to comment https://forums.phpfreaks.com/topic/129175-30-second-rule-for-post-data/#findComment-669704 Share on other sites More sharing options...
brownshoe Posted October 20, 2008 Author Share Posted October 20, 2008 Thanks for the help! I know the backslashes are there for a reason The form is actually part of a bunch of forms in a table (a script generates one for each row) like so: while ($pilot_row=mysql_fetch_array($pilots)) { $firstname=$pilot_row["first_name"]; $lastname=$pilot_row["last_name"]; $location=$pilot_row["location"]; $PilotID=$pilot_row["PilotID"]; echo "<tr>"; echo "<td>$firstname $lastname</td>"; echo "<td>$location</td>"; echo "<td> <form action=\"drop_pilot.php\" method=\"post\"> <input type=\"hidden\" name=\"PilotID\" value=$PilotID> <input type=\"hidden\" name=\"AircraftID\" value=$AircraftID> <input type=\"hidden\" name=\"registration\" value=$registration> <input type=\"submit\" value=\"Remove\"></form></td>"; echo "</tr>"; } Is it cool to have more than one form on a page like that, or is that causing some kind of problem? Like I said, if you wait 30 seconds, then hit "refresh" and then "resend post data" it works just fine. Link to comment https://forums.phpfreaks.com/topic/129175-30-second-rule-for-post-data/#findComment-669710 Share on other sites More sharing options...
Bendude14 Posted October 20, 2008 Share Posted October 20, 2008 Does each form have its own submit button? Do they all post to the same place? Link to comment https://forums.phpfreaks.com/topic/129175-30-second-rule-for-post-data/#findComment-669712 Share on other sites More sharing options...
brownshoe Posted October 20, 2008 Author Share Posted October 20, 2008 The rows are generated by the "while" loop. Each row has its own submit button. They all post to "drop_pilot.php" Link to comment https://forums.phpfreaks.com/topic/129175-30-second-rule-for-post-data/#findComment-669715 Share on other sites More sharing options...
Bendude14 Posted October 20, 2008 Share Posted October 20, 2008 try adding quote around your values variables Link to comment https://forums.phpfreaks.com/topic/129175-30-second-rule-for-post-data/#findComment-669721 Share on other sites More sharing options...
brownshoe Posted October 20, 2008 Author Share Posted October 20, 2008 hmmm... that doesn't seem to matter... I tried single quotes and double quotes (with backslashes) and it's still doing the same thing. What weirds me out is that it WORKS, you just have to refresh the page and resend the data for the script to find the post data. Link to comment https://forums.phpfreaks.com/topic/129175-30-second-rule-for-post-data/#findComment-669723 Share on other sites More sharing options...
Bendude14 Posted October 20, 2008 Share Posted October 20, 2008 well thats a sign that the vars are not be filled until after the first POST are you sure the issues is not higher up where you are querying your DB for the relevant info to fill the form? Try checking the source code before you submit at all to make sure there correct values are in the hidden fields. Link to comment https://forums.phpfreaks.com/topic/129175-30-second-rule-for-post-data/#findComment-669725 Share on other sites More sharing options...
brownshoe Posted October 20, 2008 Author Share Posted October 20, 2008 Do you think it has to do with the fact that one of the values is coming from outside the loop? AircraftID is constant for the whole page, so I didn't include it in the loop. Maybe I'll try altering my query so it picks that up, too... Link to comment https://forums.phpfreaks.com/topic/129175-30-second-rule-for-post-data/#findComment-669728 Share on other sites More sharing options...
Bendude14 Posted October 20, 2008 Share Posted October 20, 2008 check the html source and see if the values are there... Link to comment https://forums.phpfreaks.com/topic/129175-30-second-rule-for-post-data/#findComment-669731 Share on other sites More sharing options...
brownshoe Posted October 20, 2008 Author Share Posted October 20, 2008 Ah ha! Here's what's coming up in the source... <form action="drop_pilot.php" method="post"> <input type="hidden" name="PilotID" value="$PilotID"> <input type="hidden" name="AircraftID" value="$AircraftID"> <input type="hidden" name="registration" value="$registration"> <input type="submit" value="Remove"> And such. Looks like it's not showing the values right... Link to comment https://forums.phpfreaks.com/topic/129175-30-second-rule-for-post-data/#findComment-669735 Share on other sites More sharing options...
Bendude14 Posted October 20, 2008 Share Posted October 20, 2008 lol how we overlooked that i dont no hahaha <input type="hidden" name="AircraftID" value=\"echo $AircraftID\"> your not echo the values to the page Link to comment https://forums.phpfreaks.com/topic/129175-30-second-rule-for-post-data/#findComment-669741 Share on other sites More sharing options...
brownshoe Posted October 20, 2008 Author Share Posted October 20, 2008 Hmmm... I got the values to show up in the source just by taking the quotes away. The whole thing is part of a big "echo" statement, so I don't think I really need the "echo" in each field. But it still hasn't solved the problem. The HTML source is looking much more tidy... <form action="drop_pilot.php" method="post"> <input type="hidden" name="PilotID" value=1> <input type="hidden" name="AircraftID" value=2> <input type="hidden" name="registration" value=N348SP> <input type="submit" value="Remove"></form> So yeah... got THAT problem fixed. Still have to wait 30 seconds (I'm serious... I'm timing it) and then refresh the page to make it work. Link to comment https://forums.phpfreaks.com/topic/129175-30-second-rule-for-post-data/#findComment-669743 Share on other sites More sharing options...
brownshoe Posted October 20, 2008 Author Share Posted October 20, 2008 This might help... It ALSO works on the first try if I wait long enough before hitting "submit" on the form. It just has to be 30 seconds or more since the last time I posted something... Link to comment https://forums.phpfreaks.com/topic/129175-30-second-rule-for-post-data/#findComment-669745 Share on other sites More sharing options...
brownshoe Posted October 20, 2008 Author Share Posted October 20, 2008 Seems to work fine as long as I wait a while between posts. Could it be something with the browser or the server storing the data for 30 seconds? Is there some way to force it to clear itself so a new post can be entered? Thanks for the help, bendude. I'm sure the thing with not displaying the right values in the hidden fields had SOMETHING to do with it. Runs better now, but still hafta wait a little. I'm off to bed. Thanks again! Link to comment https://forums.phpfreaks.com/topic/129175-30-second-rule-for-post-data/#findComment-669747 Share on other sites More sharing options...
Bendude14 Posted October 20, 2008 Share Posted October 20, 2008 how large is the DB query? its not taking that long to retrieve the info from the DB is it? Link to comment https://forums.phpfreaks.com/topic/129175-30-second-rule-for-post-data/#findComment-669752 Share on other sites More sharing options...
brownshoe Posted October 20, 2008 Author Share Posted October 20, 2008 DB query is pretty simple... $pilots_query="SELECT `authorized_pilots`.`PilotID`, `authorized_pilots`.`AircraftID`, `users`.`UserID`, `users`.`first_name`, `users`.`last_name`, `users`.`location` FROM `authorized_pilots`, `users` WHERE `users`.`UserID`=`authorized_pilots`.`PilotID` AND `authorized_pilots`.`AircraftID`='$aircraft' ORDER BY `users`.`first_name` ASC"; Since the form is on a page that takes post data from a form on the previous page to itself, is it possible the old post data remains valid for 30 seconds and somehow blocks the new stuff? It just seems really strange to me that the post data won't be sent for 30 seconds. You can either let the page with the form sit for 30 seconds, or refresh the target page 30 seconds after you submit. Do I need to somehow close my scripts or something? I'm guessing since PHP is a server-side language that this 30 second thing has something to do with the server. Is there some way I can manually make my post data from the previous form expire sooner? Link to comment https://forums.phpfreaks.com/topic/129175-30-second-rule-for-post-data/#findComment-670099 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.