Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Sign In
Not a member yet? Click here to register.

Php coders: $var must equal $var

Ok, so I am adding something to my PF site. I am using the code


   for ($i=0;$i<=7;$i++) { $var .= chr(rand(97, 122)); }

to make a random variable. And I have a form for the user to enter in the variable (it's an input type='text').

Then I use this code:


if ($_POST['var'] == $var){
  // echo the form

And the user sees the var on the first page, but once the page reloads, the var has a new random value so the form always shows.

Any idea how I can make it a random value and not change the value per session or another way? (hopefully to do with the session)

Thanks for the reply TammyK, I never thought of using a hidden field. But this is a bit more sensitive. How would I go about checking it in the session?
It's not working.. I tried setting $var1 as the random string, and then I made $var = $_SESSION[$var1];

The checking works fine. But the $_SESSION[]; makes the value blank. And I can enter in nothing and it will work.

Why won't that make a random string and work properly?
So my previous thing should work? I believe I called session_start(); but I'm not sure. Anyway, I just changed it to somthing else, But I would prefer this way..
Thread Information
Posted In
4 posts
2135 times
Last Post
Last updated on 12 years ago
You can view all discussion threads in this forum.
You can start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You can download attachments in this forum.
Users who participated in discussion: googlebot