Jump to content

PHP Query isn't working.


Mackey18

Recommended Posts

I was doing some tutorials for PHP when i hit this little snag.

 

In one html file i wrote this:

 

<FORM ACTION="welcome.php" METHOD=GET>

First Name: <INPUT TYPE=TEXT NAME="firstname"><BR>

Last Name: <INPUT TYPE=TEXT NAME="lastname">

<INPUT TYPE=SUBMIT VALUE="GO">

</FORM>

 

Then I linked it to a PHP file with the code:

 

<?php

  echo( "Welcome to our Web site,

$firstname $lastname!" );

?>

 

<P>Today's Date (according to this Web server) is

<?php

 

 

  echo( date("l, F dS Y.") );

 

?>

 

However instead of saying: "Welcome to our Web site, Joe Bloggs!" it says "Welcome to our Web site, !"

 

Any ideas where i'm going wrong? I'm doing all of this on a local server.

Link to comment
https://forums.phpfreaks.com/topic/174878-php-query-isnt-working/
Share on other sites

Whatever tutorials your reading are VERY old and rely upon register_globals being on. This has been off by default for over 7 years.

 

Change...

 

echo( "Welcome to our Web site,
$firstname $lastname!" );

 

to....

 

echo "Welcome to our Web site, " . $_GET['firstname'] . " " . $_GET['lastname']} . "!";

Wow it worked!!! Thank you so much!!! So why didn't the code that came with the tutorial work, I mean surely they tested it before putting it up there?!?!

 

[*]When it was posted, it probably worked great. Technology changes alot over a short period of time (php6 will be here before we know it)

[*]Often tutorials are posted untested (and snippets in forums  :-[)

 

 

Archived

This topic is now archived and is closed to further replies.

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