vajra_hendry Posted August 10, 2007 Share Posted August 10, 2007 Ok so I know how to create the variables. Thats no problem. I understand how to post values to the variables using forms / links. The problem is simple : If some on my site selects a link that changes a variable e.g. $var1 = 10 So thats cool but in about 10 mins time the script will need to go back to $var1 and refer to the value that the user previoulsy selected. So in this case the value is 10! So lets says seconds later after $var1 was set to '10' somone else logs into my site and clicks another link that changes $var1 = 20 So that would screw things up I guess. So that variable that is being changed, is it specific to the user who set it, or is the variable centrally located on the server? Cos potentially what now happens is my customer (yeah the one that set $var1 to 10) gets to the part in the script and it recalls $var1 = 20 so the customer is going to be like . . . well thats wrong, I selcted a different option! God does that make sense!! haha. Any help for a humble noob would be welcomed Thanks Quote Link to comment https://forums.phpfreaks.com/topic/64202-solved-ok-im-a-noobe-question-about-variables/ Share on other sites More sharing options...
btherl Posted August 10, 2007 Share Posted August 10, 2007 Hmm, I'm a little confused by what you are saying. But I'm pretty sure that sessions will help. Try the following: <?php session_start(); print "Old value was " . $_SESSION['var'] . "<br>"; $_SESSION['var'] = $_GET['var']; print "New value is " . $_SESSION['var']; ?> <form action="" method=get> <input name=var type=text value="<?php echo $_SESSION['var']; ?>"> <input name=Submit type=Submit value=Submit> </form> When you use session_start(), all variables inside $_SESSION are remembered until the user closes the browser (at least with default configurations) Quote Link to comment https://forums.phpfreaks.com/topic/64202-solved-ok-im-a-noobe-question-about-variables/#findComment-320044 Share on other sites More sharing options...
vajra_hendry Posted August 10, 2007 Author Share Posted August 10, 2007 I think thats exactly what I needed to know!! Thanks Quote Link to comment https://forums.phpfreaks.com/topic/64202-solved-ok-im-a-noobe-question-about-variables/#findComment-320046 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.