Page 1 of 1

$_GET and $_POST

Posted: Tue Aug 23, 2005 10:55 am
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]

Posted: Tue Aug 23, 2005 10:59 am
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="";

Posted: Tue Aug 23, 2005 11:04 am
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"].

Posted: Tue Aug 23, 2005 11:30 am
by ale2121
you rock!! thanks :D

Posted: Tue Aug 23, 2005 12:38 pm
by feyd
FYI: The General Discussion board is not a place to ask code questions.


Moved to PHP - Code.