Hi everyone, I’m need to pass a random number I generated to another web page. All the examples I’ve seen are passing the variable’s value, which I don’t know.
Example… action="http://page-1.php?random=8423"
I’ve seen where you can pass a value thru a URL, which would work except I know the value.
My random number variable is $random.
Can someone please offer suggestions or tell me if my idea is completely wrong?
I’m sorry it took so long to respond and that I wasn’t very clear expressing my question, but you gave me the answer I needed. I didn’t realize I could put php in the action statement.
Can you put any php code there? Could I do something like this?
Hi, yes you can put whatever you like there… but your format is a little off. Try it this way:
[php]action=“http://page-1.php?random=<?php substr(number_format(time() * rand(),0,'',''),0,8); ?>”[/php]
valandor062 had the variable $random in the url like that because it allows you to format things more cleanly, and you can use the variables elsewhere in your code. For example:
[php]$random = substr(number_format(time() * rand(),0,’’,’’),0,8);
// And your URL now is
action=“http://page-1.php?random=<?php echo $random; ?>”>Link Text
// I still want to use the $random variable, for example set it to a session to use on other pages
$_SESSION[‘random’] = $random;
[/php]