Re: PHP scripts and IE

From: Geoff Berrow (blthecat_at_ckdog.co.uk)
Date: 01/30/05


Date: Sun, 30 Jan 2005 01:31:28 +0000

I noticed that Message-ID: <cthahu$7gm$1@sparta.btinternet.com> from
Tony Wainwright contained the following:

>Sorry Geoff, just learning - if you could point out what is wrong with the
>code I would appreciate it. And perhaps suggest a better book (I am using
>PHP, MySQL and Apache All in One, published by Sams)

Actually it's not bad enough to cause the error but I think it could
lead you into bad habits. I find it easier to be consistent in my use
of superglobals and use them like so :- $_POST['user']

If you tried to do
echo $_POST[user];
You would get a warning notice. It only works in your case because it
is contained within double quotes. I find it simpler to use just one
way. Unfortunately this means you have to write the lines as:-

echo "<p>Welcome <b>".$_POST['user']."</b>!</p>";
echo "<p>Your message is:<br><b>".$_POST['message']."</b></p>";
But it saves you having to think of whether to use single quotes or not.

Also, it's a good idea to check if variables exist before using them. I
know this script won't get called unless the POST variables exist, but
again it's all about good habits.

As for your original problem. Sorry, can't recreate it - it works fine
in IE here.

-- 
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/


Relevant Pages

  • Re: PHP scripts and IE
    ... Unless I'm mistaken the original code actually won't work no matter what - ... > But it saves you having to think of whether to use single quotes or not. ... > know this script won't get called unless the POST variables exist, ... > again it's all about good habits. ...
    (alt.php)
  • Re: Beginners Program
    ... > bad habits, so I would like to pick them up now. ... No need to escape '#' characters. ... altogether by using single quotes: ... bclennox AT eos DOT ncsu DOT edu ...
    (comp.lang.perl.misc)