Jump to content

help understanding hidden input w/ php


kirkh34

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/185815-help-understanding-hidden-input-w-php/
Share on other sites

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 :)

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.