Problems using $_POST variables

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I'm trying to convert someone's code written using register global variables
to using $_POST.
So I find lot's of cases where the writer has used if ($update) .... which
is passed in the url of the page like page.php?update=something.
So I replaced $update with $_POST['update'] in the test and this usually
works, except when printing/echoing into strings.
So a line like
print $update ; if replaced by print $_POST['update'] ; does not work, the
script seems to crash with no output.
If I write
$update=$_POST['update']  ;
echo $update ; this works.
Another example is in javascript script which contains
<?php echo "faq_admin.php?var1=$var1&var2=$var2" ?>
If I change it to
<?php echo "faq_admin.php?var1=$_POST['var1']&var2=$_POST['var2']" ?>
it crashes.

I'm missing something about the $_POST variables. Can someone point ot an
explanation ?

Re: Problems using $_POST variables

Tony B wrote:

Quoted text here. Click to load it

<?php echo "faq_admin.php?var1=&var2=" ?>

Though you should probably pass that whole lot through htmlentities() for
security reasons:

<?php echo
htmlentities("faq_admin.php?var1=&var2="); ?>

Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux, up 37 days, 23:47.]

                               Bottled Water

Re: Problems using $_POST variables

Quoted text here. Click to load it


Try $_GET.

Site Timeline