•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 426,483 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,171 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 585 | Replies: 2
![]() |
is it possible to generate a random number and then use cookies to pass this number to other page?
i cannot use session_start because it does not like my code for resizing the images that are uploaded and i cannot use get as the page the the random number is in a iframe and has no buttons on to append it to the url.
i have tried to post the data but had no joy the variable $rand has no value when checked on the next page. the code i used for the submit button looks like this
and the code i used to retrieve the value looks like this
i cannot use session_start because it does not like my code for resizing the images that are uploaded and i cannot use get as the page the the random number is in a iframe and has no buttons on to append it to the url.
i have tried to post the data but had no joy the variable $rand has no value when checked on the next page. the code i used for the submit button looks like this
<form name="newad" method="post" enctype="multipart/form-data" action=""> <input type="hidden" method="<?=$rand;?>" name="rand" /> <input type="file" name="broad1_image" ></td></tr> <input name="Submit" type="submit" id="image1" value="Upload image" ></td></tr> </form>
and the code i used to retrieve the value looks like this
$rand= $_POST['rand'];
•
•
Join Date: May 2008
Location: Swindon, UK
Posts: 141
Reputation:
Rep Power: 1
Solved Threads: 22
Before the form you will need to generate the random number, also you have specified no value for the hidden field, change method= to value=.
To generate the random number do something like this:
To generate the random number do something like this:
<? // mt_rand(min value, max value) $rand = mt_rand(); ?>
•
•
Join Date: Apr 2005
Location: New York state
Posts: 468
Reputation:
Rep Power: 5
Solved Threads: 71
<input type="hidden" value="<?=$rand ?>" name="rand" />
method only applies to the form tag. Last edited by ShawnCplus : May 9th, 2008 at 2:29 pm.
GCS d- s+:+ a-->? C++(++++) UL+++ P+>+++ L+++ !E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r z+*
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r z+*
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Need Help (PHP)
Other Threads in the PHP Forum
- Previous Thread: what's the code of changing password...?
- Next Thread: a little help


Linear Mode