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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.