Forum Moderators: coopster
Lets take the $HTTP_POST_VARS built in array. I`m confused at how and when I need to use it.
If I have a basic contact form:
<form method="post" action="<? PHP_SELF;?>">
Name: <input type="text" name="name">
E-Mail: <input type="text" name="email">
Message: <textarea name="comments" rows="6" cols="45"></textarea>
<input type="submit" name="submitform"
value="Submit" title="Submit"></form>
So, I do some syntax as follows:
if ($HTTP_POST_VARS['submitform'])
{
do actions
}
Is that the only time I need to use the built in array? If I call to the variables $name, $email, or $comments do I need to use $HTTP_POST_VARS['name'] etc etc?
And what about functions? If I`m using $name, $email or $comments inside another function, should I declare $HTTP_POST_VARS as a global variable in the function? As you can see I`m a little confused. I`ve been looking at some other scripts for some guidelines, but would be interested to hear your thoughts.
Any help you can give me would be appreciated. Or if there are any online tutorials you can point me to, that would be just as good.
Thank you! :)
You can use $_POST[] pretty much anywhere in your script, aside from classes I think (someone knows for sure?).
What I like to do is simply intialize the vars I need at the beginning of the script like for example:
if(isset($_POST['submit'])) { $submit = $_POST['submit']; }
and then I pass those to my function as parameters but that's just me.
If you need more info, the manual [php.net] is your friend.
mavherick