Jump to content

Recommended Posts

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

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)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.