LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-28-2005, 03:29 AM   #1
sleepisforwimps
Member
 
Registered: Apr 2005
Location: Susex, England.
Distribution: Slackware 10.1, Devil Linux
Posts: 49

Rep: Reputation: 15
Newbie PHP question


I've just started learning PHP and have already hit a bug I can't figure out. I'm trying to write a program that accepts input from the address bar and alters the output accordingly. Here is a simplified form of the script:

Code:
<html>
<head>
  <title>PHP test page</title>
</head>
<body>

  <?php
    if ($Name == "Bob") {
      print ("Welcome Bob.");
    } else {
      print ("Hello there.");
    }
  ?>

</body>
</html>
The idea is that when the user types just the name of the file (say "test.php" into the address bar the out is "Hello there." but when he type "test.php?Name=Bob" the output is "Welcome Bob." The server I'm running it on is one I set up myself with Slackware 10.1 running Apache 1.3.33 and PHP 4.3.10. Unfortunately the program only outputs "Hello there." and typing "test.php?Name=Bob" doesn't achieve the desired effect. PHP is working on the server as I get expected output without the Name parameter but adding "Name=Bob" doesn't work. Is there something wrong with my script or is it possible that my server is misconfigured somehow?
 
Old 08-28-2005, 03:51 AM   #2
spooon
Senior Member
 
Registered: Aug 2005
Posts: 1,755

Rep: Reputation: 51
Try using $_REQUEST['Name'] (new versions) or $_GET['Name'] instead of $Name because it comes from a GET form. Alternately, if you want to use $Name, you can import it by import_request_variables('gp') first. See here for more information:
http://www.php.net/manual/en/languag...s.external.php
 
Old 08-28-2005, 04:06 AM   #3
sleepisforwimps
Member
 
Registered: Apr 2005
Location: Susex, England.
Distribution: Slackware 10.1, Devil Linux
Posts: 49

Original Poster
Rep: Reputation: 15
Thank you, it's working!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP question (newbie) matthewchin Programming 2 12-05-2005 09:46 PM
Kind of a newbie question On PHP compiling. Junior41180 Linux - Software 2 02-10-2005 09:01 PM
PHP newbie question jacksmash Programming 20 11-22-2003 11:52 AM
Newbie and PHP david63 Linux - Newbie 3 05-08-2003 03:18 AM
Apache newbie question.. (very newbie question) tarballed Linux - Newbie 1 02-07-2003 08:41 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration