$_GET and $_POST

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ale2121
Forum Newbie
Posts: 23
Joined: Tue Aug 23, 2005 9:56 am

$_GET and $_POST

Post by ale2121 »

hi all,
i've been having some major problems getting this to work. my server has php 4.3, but has register-globals turned on. I was trying to use $_GET, and $_POST, but instead, had to use $HTTP_GET_VARS etc. but now, i'm trying to use $_SERVER['PHP_SELF'] (i've also tried $HTTP_SERVER_VARS['php_self']). my forms return no info.
here's the code:

Code: Select all

<?php

if (isset($_POST['submit'])) {
	if (strlen($_POST['first']) > 0) {
		echo "Thanks {$_POST['first']}";  
	} else { // The source is not right.
		echo "<p><b>please enter a name</b></p>";
	} 
} else {

?>
<form action="<?php echo $_SERVER['license.php']; ?>" 
          method="POST">first name<input type="first" name="$first">
<input type="submit" name="submit" value="thanks"></form>
<?php
}
?>
if there's a dumb error in this, you can point it out, but this is only the latest incarnation of a lot of tries, i'm pretty sure the error is something important that I'm just not getting.
Also, I want to use the most secure way possible to do this, although it seems to me that sending the form data to itself is quite secure? yes, no ?


feyd | Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

What is this in the form action:

Code: Select all

<?php echo $_SERVER['license.php']; ?>
If all else fails leave the form action empty: action="";
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post by nielsene »

Code: Select all

<?php 

if (isset($_POST['submit'])) { 
if (strlen($_POST['first']) > 0) { 
echo "Thanks {$_POST['first']}"; 
} else { // The source is not right. 
echo "<p><b>please enter a name</b></p>"; 
} 
} else { 

?> 
<form action="<?php echo $_SERVER['license.php']; ?>" 
method="POST">first name<input type="text" name="first" value="$first"> 
<input type="submit" name="submit" value="thanks"></form> 
<?php 
} 
?>
You weren't giving your form input "first" a valid type.

There's no such variable as "_SERVER["license.php']" you might want
_SERVER["PHP_SELF"].
ale2121
Forum Newbie
Posts: 23
Joined: Tue Aug 23, 2005 9:56 am

Post by ale2121 »

you rock!! thanks :D
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

FYI: The General Discussion board is not a place to ask code questions.


Moved to PHP - Code.
Post Reply