Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

$_POST and register_globals=off 1

Status
Not open for further replies.

kodr

Programmer
Joined
Dec 4, 2003
Messages
368
I know there's a lot of information out there, but I'm just not making sense of this.

I've got a server using php 5.1.6, and register_globals is off by default. Cool.

If I'm understanding everything correctly, I should be retrieving my variables using $_POST.

Code:
$user_name = $_POST["username"];

Is this correct?

With my test set up, I can pass username to a following php script with:

Code:
        echo '<form action="on_callv2.php" method="post">';
        echo '<input type="hidden" name="username" value="'.$user_name.'">';
        echo '<select name="tech">';
 ..........
        echo '</select>';
        echo '<br><br><input type="submit" value="Submit">';
        echo '</form>';

This doesn't seem to be working for me. Any ideas? Right now, I've gone in an turned register_globals=on, but I'd rather have it done right at this stage.

Thanks.
 
Not sure what you are attempting to do?

Are you trying to get the value pre-populated into the hidden input type?


Basically what you have is a chicken-egg loop.

You are trying to populate a form input with a value generated from it. So which one is supposed to have a value first?


Can you maybe explain what you are attempting to do?

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
The sample I posted is after my login.html and login.php pages. The login.php script receives the data fine from the login.html page. But after I validate it, I want to pass it to the oncallv2.php script.

This script doesn't seem to be receiving the data. I thought that by setting it in a hidden type field within the form would pass it forward to the next script.
 
this is probably a scope issue.
does this work instead?
Code:
<?php
echo <<<HTML
<form action="on_callv2.php" method="post">
<input type="hidden" name="username" value="{$_POST['username']}">
<select name="tech">
</select> 
<br/><br/>
<input type="submit" value="Submit">
</form>
HTML;
?>
note that this may throw an error/notice if the form has not yet been submitted.

note also that this is not the best way of making data persistent between pages. it is better to use sessions for such a purpose.
 
But after I validate it, I want to pass it to the oncallv2.php script.

How?
Does your login.php page generate the form you provided there? Or is that form inside on_callv2.php?

The basic concept is that the POST variable is only available to the script it posts to in your case the values from login.html would be available to login.php, but not available directly to on_callv2.php.









----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
jpadie,

Thanks for the tip on sessions. Looks like that was the piece that I was misssing.

Everything I read about register_globals said to use $_POST, but nothing went much farther then that.

I'm going to convert all of the post data I'm passing to session.
 
So the form in your code is a third page between login.php and on_callv2.php.

Then yes you'll need Sessions. Once you have everything validated in login.php you should create your sessions vars there in login.php with the info you want to make available to on_callv2.php.



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top