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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Localhost Problem??

Status
Not open for further replies.

scripter50

IS-IT--Management
Dec 9, 2002
35
0
0
US
I have some basic code that will not work on my localhost, but works just fine on my website?? Is there something in the php.ini that needs to be changed? Just setting a hidden field with js and submitting??

<html>
<head>
<title>Test Page</title>
<script language = "javascript" type = "text/javascript">

function fnValidate() {
var form = document.frmTest;

form.hdnStage.value = "1";
form.submit();
}

</script>
</head>
<body>
<form name="frmTest" method="post" action="testPage.php">
<input type="hidden" name="hdnStage" value="">

<?php
if (empty($hdnStage)) {
?>

Show this initial text....<br><br>
<input type = "button" name="btnSubmit" value="Submit" onclick="fnValidate()">

<?php
}
else {
?>

Show this resulting text....

<?php
}
?>

</form>
</body>
</html>
 
Yes it's called register_globals and it defaults to off.

when its off, the names of the form objects such as textboxes and hidden fields don't automatically translate to exisitng variables.

$hdnStage.

instead you have to access them via the Superglobal arrays $_POST or $_GET depending on the method of your form.

That your webhost has them turned on is a major security risk, as outlined in the PHP online manual.
I suggest you get used to using the supergrlobal variables to access your forms objects instead. As most webhosts keep thme off for securty purposes.

so to access the hdnStage variable you'd do:
$_POST['hdnStage'];



----------------------------------
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