Page 1 of 1

how to check a hidden field data

Posted: Tue Oct 06, 2009 4:47 pm
by eliavozeri
hi i was looking for a way to make the subject understandable but couldn't find the right phrase so here is the deal...
i have a template in which i have a variable called $body.
i have created a file called register.php in which i call the template and set the $body variable to an html table.
in this html table i have a hidden field called registerinfo i want to use this variable as a flag so i can either show the html table if the user hasen't registered yet and if he presses the register button i call the register.php file again and now i want insted of the html table a simple text saying register succesfull.
this is what i did:

Code: Select all

 
extract($_POST); 
 
    if (empty($registerinfo))
        {
            $registerinfo="1";
            $body=$registerTable;
        }
    else
        {
            $body="<font size=1px><b>You have succesfuly registerd<br>";
        }
 
 
include_once("template.php");
 
now i do understand that useing the extract($_post) could cause breeches in security i don't mind that right now.
and if someone could explain to me the difference between include and include_once i would be happy.
what should i use? as they both work with no problem.
thanks for the help

Re: how to check a hidden field data

Posted: Tue Oct 06, 2009 5:19 pm
by requinix
The question is whether to use include or include_once?

include() will let you include the same file more than once. include_once() will not. You decide.

Personally, I would use include() if I needed the file to do something for me. Immediately. Like if, instead of functions, you had lots of files with code*. I don't use include_once because in cases where I would use it I'd actually use require_once instead.

* Do. Not. Use. This. Method.

Re: how to check a hidden field data

Posted: Tue Oct 06, 2009 5:33 pm
by eliavozeri
ok thanks for the info the question though was the above statment
the part about the include is just one more thing i added to the post. it kind of drove me nuts to see both work and not understand what i should use.