kirkh34 Posted December 20, 2009 Share Posted December 20, 2009 hello i'm doing a tutorial where there are multiple forms for an edit page for a user to update their info... there's a section of the code i dont really understand how it works...here's code: php: if ($_POST['parse_var'] == "edit"){ (more php code that executes..) } html: <form action="edit.php" enctype="multipart/form-data" method="post" name="edit" id="edit"> <input name="edit" type="text" class="formFields" id="edit" value="" size="36" maxlength="32" /> <input type="hidden" name="parse_var" value="edit" /> <input type="submit" name="button1" id="button1" value="Submit" /> </form> i dont understand how the "parse_var" and "edit" correlate? the parse_var is the same on every other form and the "edit" would be something different on another form, what "edit" is it specifically talking about and how are they working with each other here? Quote Link to comment Share on other sites More sharing options...
JAY6390 Posted December 20, 2009 Share Posted December 20, 2009 Its likely that there are a few actions the edit.php script can run depending on the parse_var. edit is one of them Quote Link to comment Share on other sites More sharing options...
nafetski Posted December 20, 2009 Share Posted December 20, 2009 Link us the tutorial? I'd imagine they have one script that handles inserts and edits...allt hat hidden input field is doing is passing a flag to the script to let it know that it's an edit and not an insert (i'd imagine). If you link me the tutorial I can have a better idea and hopefully get ya pointed in the right direction Quote Link to comment Share on other sites More sharing options...
oni-kun Posted December 21, 2009 Share Posted December 21, 2009 Note the value of the POST element in the form. It is value="edit", Therefor the $_POST['parse_var'] will POST as edit as the hidden value states. This may be meant to prevent bots from POST'ing a value, as they'd most likely not even see the hidden variable and the "$_POST['parse_var] == 'edit' " will be false. Quote Link to comment Share on other sites More sharing options...
kirkh34 Posted December 21, 2009 Author Share Posted December 21, 2009 ohh awesome, i got ya, that's pretty cool, thanks for the information, i just don't like passing up code i dont understand even though it works, the more knowledge the better 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.