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

$variable vs. variable?

Status
Not open for further replies.

ProgramminFool

Technical User
Oct 26, 2003
10
CA
This code shows what I expect: a submit button which when pressed will load the same page again with the words 'Submit was pressed' only appearing.

When I try this with $hasPassed instead of hasPassed, which is the way I thought I was 'supposed' to write PHP, it doesn't work...
Suggestions?

<?php

if(hasPassed)
{
echo &quot;Submit was pressed&quot;;
}

if(!hasPassed)
{
?>
<form method=&quot;post&quot; action=&quot;my_test.php&quot;>
<input type=&quot;hidden&quot; value=&quot;something&quot; name=&quot;hasPassed&quot;>
<input type=&quot;submit&quot; value=&quot;Submit!&quot;>
</form>
<?php
}
?>

-------------------------------------------------
“Talent is cheap, dedication is expensive. It will cost you your life.”
 
No, neither produced any error messages.
The way without the '$' symbols worked as I expected, and the one with the '$' symbol didn't *appear* to change anything (the page reloaded displaying the same thing)

Since then I have found ways to work with the 'proper' notation, and while I don't understand why the above code worked, I know how to do it the 'right' way now.

Thanks for your time.

-------------------------------------------------
“Talent is cheap, dedication is expensive. It will cost you your life.”
 
Depends of your php.ini settings but may be you should do this at first:

$hasPassed = $_POST[&quot;hasPassed&quot;];
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top