PHP $_GET and $_POST problem

GET and POST function doesn't seem to work when i run it.

Page 1 of 1

10 Replies - 3804 Views - Last Post: 16 July 2009 - 12:25 PM Rate Topic: -----

#1 scion33  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 18-May 09

PHP $_GET and $_POST problem

Posted 16 July 2009 - 04:07 AM

Hello everyone I'm learning PHP and Im trying to run and test GET and POST but I seem to get an error. Please help me fix this problem.

<!-- welcome.php file-->
<html>
<body>
Welcome <?php echo $_GET["fname"]; ?>.<br />
You are <?php echo $_GET["age"]; ?> years old! 
</body>
</html> 
 


<!-- welcome.htm file-->
<html >
<body>
<form action="welcome.php" method="get">
Name: <input type="text" name="fname" />
Age: <input type="text" name="age" />
<input type="submit" />
</form> 
</body>
</html>



Expected Result Example:

Welcome ryan.
You are 12 years old!

But I get only this result:

Welcome .
You are years old!


the name and age value from the user input didn't show up. I have tried this using IIS and apache both have the same results pls. help Im running VISTA computer.. if its not the codes.. there must be some problem from my configurations or intsallation.. Please i really need this. thank you very much.

Is This A Good Question/Topic? 0
  • +

Replies To: PHP $_GET and $_POST problem

#2 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3001
  • View blog
  • Posts: 10,393
  • Joined: 08-August 08

Re: PHP $_GET and $_POST problem

Posted 16 July 2009 - 04:28 AM

Works for me, and I copy/pasted your code. This is on a Mac with Apache.
Was This Post Helpful? 0
  • +
  • -

#3 Austinkir  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 39
  • Joined: 20-March 09

Re: PHP $_GET and $_POST problem

Posted 16 July 2009 - 08:53 AM

View Postscion33, on 16 Jul, 2009 - 03:07 AM, said:

Expected Result Example:

Welcome ryan.
You are 12 years old!

But I get only this result:

Welcome .
You are years old!


Are you running it on a web server with php installed? Correct me if I'm wrong, but it sounds like your trying to run it from your local computer (and I'm assuming you don't have it set up as a server?).
Was This Post Helpful? 0
  • +
  • -

#4 RPGonzo  Icon User is offline

  • // Note to self: hmphh .... I forgot
  • member icon

Reputation: 151
  • View blog
  • Posts: 954
  • Joined: 16-March 09

Re: PHP $_GET and $_POST problem

Posted 16 July 2009 - 09:03 AM

MACs have the ability to run PHP locally so there is no need for a web server ... Basically a local web server :D

EDIT:
I tested locally with XAMPP with no issues as well as on a web host with no issues ...

Quote

Welcome My Name.
You are 5 years old!


of course i typed "my name" and "5" so -_-

This post has been edited by RPGonzo: 16 July 2009 - 09:06 AM

Was This Post Helpful? 0
  • +
  • -

#5 aroymart  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 49
  • Joined: 22-February 09

Re: PHP $_GET and $_POST problem

Posted 16 July 2009 - 10:19 AM

<html>
<body>
Welcome <?php echo $_POST["fname"]; ?>.<br />
You are <?php echo $_POST["age"]; ?> years old!
</body>
</html> 


i always use it like this

edit: oh i didnt know you used get, try making the method post

This post has been edited by aroymart: 16 July 2009 - 10:20 AM

Was This Post Helpful? 0
  • +
  • -

#6 Austinkir  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 39
  • Joined: 20-March 09

Re: PHP $_GET and $_POST problem

Posted 16 July 2009 - 10:31 AM

View PostRPGonzo, on 16 Jul, 2009 - 08:03 AM, said:

MACs have the ability to run PHP locally so there is no need for a web server ... Basically a local web server :D


Thats so BA, good to know!
Was This Post Helpful? 0
  • +
  • -

#7 scion33  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 18-May 09

Re: PHP $_GET and $_POST problem

Posted 16 July 2009 - 11:52 AM

View PostAustinkir, on 16 Jul, 2009 - 07:53 AM, said:

View Postscion33, on 16 Jul, 2009 - 03:07 AM, said:

Expected Result Example:

Welcome ryan.
You are 12 years old!

But I get only this result:

Welcome .
You are years old!


Are you running it on a web server with php installed? Correct me if I'm wrong, but it sounds like your trying to run it from your local computer (and I'm assuming you don't have it set up as a server?).



yes i am running it on my laptop with IIS 7 and xampp installed.. how can i test it with my local computer without setting it up as a server? is it possible? thanks
Was This Post Helpful? 0
  • +
  • -

#8 RPGonzo  Icon User is offline

  • // Note to self: hmphh .... I forgot
  • member icon

Reputation: 151
  • View blog
  • Posts: 954
  • Joined: 16-March 09

Re: PHP $_GET and $_POST problem

Posted 16 July 2009 - 11:58 AM

If you have XAMPP installed just make sure the apache module is started and you should be able to access it as long as you have it in the right folder ...
Was This Post Helpful? 0
  • +
  • -

#9 scion33  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 18-May 09

Re: PHP $_GET and $_POST problem

Posted 16 July 2009 - 12:04 PM

View Postaroymart, on 16 Jul, 2009 - 09:19 AM, said:

<html>
<body>
Welcome <?php echo $_POST["fname"]; ?>.<br />
You are <?php echo $_POST["age"]; ?> years old!
</body>
</html> 


i always use it like this

edit: oh i didnt know you used get, try making the method post


I have tried both functions GET and POST both have same results. i tested them both with IIS server and Xampp (Apache) . So i think i must be missing somtething. Running it on my laptop only with VIsta. I'm really not sure what to do now.
Was This Post Helpful? 0
  • +
  • -

#10 RPGonzo  Icon User is offline

  • // Note to self: hmphh .... I forgot
  • member icon

Reputation: 151
  • View blog
  • Posts: 954
  • Joined: 16-March 09

Re: PHP $_GET and $_POST problem

Posted 16 July 2009 - 12:20 PM

There is a special install for xamp on vista for it to run properly because of user permissions ... if these weren't followed you possibly will not be able to get it to work ...

Also make sure your xampp console is open ( or at least running in the tray ) and that Apache has a green label with the text "running" next to it
Was This Post Helpful? 1
  • +
  • -

#11 scion33  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 18-May 09

Re: PHP $_GET and $_POST problem

Posted 16 July 2009 - 12:25 PM

View PostRPGonzo, on 16 Jul, 2009 - 10:58 AM, said:

If you have XAMPP installed just make sure the apache module is started and you should be able to access it as long as you have it in the right folder ...


OH thanks i put it on htdocs... it now works.. yah i guess i got used to testing them locally and not using the server.. So i thought im already using the server.. Thanks a lot. it worked

Thanks everyone for the time and helping me.. I really have lots to learn in programming. i really appreciate all your help .. thanks. (^_^)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1