Click to See Complete Forum and Search --> : PHP question


MaGneTTo
06-02-2002, 07:58 PM
Hi guys, i was just wondering, i'm trying to study a little bit of php and i came up with this problem, let's say i have the following:

<form method="post" name="insert" action="confirm.php">
<input type="text" size="30" name="description">
</form>

since i have print the value of $description when the user loads confirm.php, i was just wondering that if i do like this
URL: localhost.localhost/page/confirm.php?description=test
it prints out "test" instead the value of the original variable, what i'm trying to do is to avoid the GET information from overwrinting the POST information, any ideas ? One other thing, it would be amazing to also avoid the user from accesing URL://localhost.localdomain/page/confirm.php without having passed through index.php first.

EscapeCharacter
06-03-2002, 02:56 AM
dont about your first question but you can avoid people from going to the confirm page by passing some hidden value from index and if the value for that varible isnt correct itll do one thing instead of displaying what it should be

Whipping Boy
06-03-2002, 01:19 PM
Actually, a better solution would be to check the HTTP_REFERER environment variable (assuming it's enabled on your server).

Greed
06-03-2002, 10:38 PM
Originally posted by Whipping Boy:
<STRONG>Actually, a better solution would be to check the HTTP_REFERER environment variable (assuming it's enabled on your server).</STRONG>

Yes, this is what I do with my php pages. For example, I have to have users fill out a form, and then the information from that form gets sent to a database. Lets say we use the code mentioned earlier...then simply do something like this to display it....


echo $description


Very easy, took me a long time to figure this one out when I was first starting out... (It can't be *that* easy, can it?!?!)

The documentation available at php.org is invaluable, I would suggest taking a look at that...

Stuka
06-04-2002, 01:54 PM
I had a similar situation, where I needed to ensure that the user had input the minimum required answer - all I did was test for the variables, and if they weren't there, I kicked 'em back to the previous page with a redirect header...I used this since it really didn't matter WHERE they came from, or what was enabled on the server...