Forum Topic: Php: Simple $_get Workings

(726 views • 5 replies)

This topic is 1 page long.

<< < > >>
None

SpamBurger

Reply To Post Reply & Quote

Posted at: 9/17/06 04:56 PM

SpamBurger NEUTRAL LEVEL 15

Sign-Up: 07/12/05

Posts: 4,747

That was pretty much already covered here, but I guess you explained it in more detail.

"However, the game received only two orders, one of which Molyneux speculated was from his mother." -Peter Molyneux's first game The Entrepreneur


None

WoogieNoogie

Reply To Post Reply & Quote

Posted at: 9/17/06 05:44 PM

WoogieNoogie LIGHT LEVEL 14

Sign-Up: 06/26/05

Posts: 3,284

It's alot easier and all-around better, I belive, to use the POST method with forms, for a few reasons.

One, the GET method is used with putting variables in the URL of the PHP page. I like to use both at the same time, every once in a while, such as in my forum system where I want the post to go in the topic, but the topic ID is not part of the form....if that makes sense.

Second, it's alot more effecient to send the form action to itself, and check to see if the data was given. Ex:

form.php
<?php
if(isset($_POST['name'])) {
$name = $_POST['name'];
echo "Your name is $name!";
} else {
echo "<form action='form.php' method='post'>
<input type='text' size='20' name='name'>
<input type='submit' value='Submit!'>
</form>";
}


None

Craige

Reply To Post Reply & Quote

Posted at: 9/17/06 08:23 PM

Craige LIGHT LEVEL 08

Sign-Up: 07/17/04

Posts: 3,072

At 9/17/06 05:44 PM, WoogieNoogie wrote: Second, it's alot more effecient to send the form action to itself, and check to see if the data was given. Ex:

Only in some cases.


None

WoogieNoogie

Reply To Post Reply & Quote

Posted at: 9/17/06 10:04 PM

WoogieNoogie LIGHT LEVEL 14

Sign-Up: 06/26/05

Posts: 3,284

At 9/17/06 08:23 PM, Craige wrote: Only in some cases.

Right, I forgot to mention that...I was sure thinking it though, since I rarely send forms to themselves.


None

Craige

Reply To Post Reply & Quote

Posted at: 9/17/06 10:08 PM

Craige LIGHT LEVEL 08

Sign-Up: 07/17/04

Posts: 3,072

Oh, and one thing Neill:

REQUEST does the same thing as GET in the PHP file:
You are <?php echo $_REQUEST["age"]; ?> years old!

You shouldn't say that. You don't want to get people confused. $_REQUEST contains $_POST, $_GET, and I think $_COOKIE. So you should be carefull where using it.


None

DFox

Reply To Post Reply & Quote

Posted at: 9/17/06 10:09 PM

DFox LIGHT LEVEL 30

Sign-Up: 08/09/03

Posts: 9,489

It's a good tutorial.

Making a tutorial that's been done before is fine. Some people learn better from reading different tutorials on the same subjects.

As for posting to a different page, there's nothing wrong with that.

My dad's been programming for 25 years, and when he writes PHP and ASP scripts, he always posts to a different page as he finds it easier to maintain.

As for me, I would never post to anything except the page where the form is, so everyone is different.


All times are Eastern Standard Time (GMT -5) | Current Time: 10:48 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!