Maintaining value of a variable through many pages in PHP WITHOUT COOKIES,SESSIONS -
i having problem in maintaing value of variable through several pages(actually through same page through many refresh).
first time navigated new page value of variable preserved , can used echo,but after refreshing page value cannot reused,it shows error variable has no value.
making webapp chatting in php.
want show name of user(sender) on every page(every page of sending message). using code
<?php $writtervar = $_post['writter']; echo $writtervar; ?>
i taking input through separate page,code is
<form action="ddd.php" method="post"> enter name <input type="text" name="writter" > <input type="submit" id="submit" value="press" > </form>
you can use session. base on code can try this: in start page (ddd.php) have set session values.
<?php session_start(); $_session["writer"] = $_post["writter"]; ?> ...
in other page use session values e.g:
<?php session_start(); ... echo $_session["writer"]; ?>
note unset , destroy session @ end off work.
<?php // remove session variables session_unset(); // destroy session session_destroy(); ?>
Comments
Post a Comment