Reputation: 451
I'm looking to send my session variable: $_SESSION['steamid'] to another webpage by using a form. I also want to have a disabled text form with the variable in it.
Currently, this is the code I have:
$variable = $_SESSION['steamid'];
and
<input type="hidden" name="b64id" value="'$variable'"/></br>
<p>Your 64 ID: <input type="text" name="b64id" value="'$variable'" disabled="disabled"/></br>
But I am just recieving "$variable" on the other end. I would like to avoid using POST and Cookies but if it's needed I'm happy to use it. I can ensure that $variable has a value.
Upvotes: 0
Views: 202
Reputation: 1693
when you want to use PHP variable you should open PHP tag
NOT CORRECT
<input type="hidden" name="b64id" value="'$variable'"/></br>
<p>Your 64 ID: <input type="text" name="b64id" value="'$variable'" disabled="disabled"/></br>
CORRECT
<input type="hidden" name="b64id" value="<?php echo $variable ?>"/></br>
<p>Your 64 ID: <input type="text" name="b64id" value="<?php echo $variable ?>" disabled="disabled"/></br>
there is a short form <?= $variable ?>
it means <?php echo $variable ?>
WELCOME ON PHP WORD !!!
Enjoy :)
Upvotes: 0
Reputation: 23816
Use following code having php tags:
<input type="hidden" name="b64id" value="<?php echo $variable ?>"/></br>
<p>Your 64 ID:
<input type="text" name="b64id" value="<?php echo $variable ?>" disabled="disabled"/>
</br>
You should also check if session
having value or not.
like:
$variable = (isset($_SESSION['steamid']))?$_SESSION['steamid']):'';
Upvotes: -1
Reputation: 219804
Two issues:
This should do what you need (assuming PHP 5.4+ or short tags enabled):
<p>Your 64 ID: <input type="text" name="b64id" value="<?= $variable ?>" disabled="disabled"/></br>
Upvotes: 3