User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Feb 2008
Posts: 298
Reputation: kevin wood is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
kevin wood's Avatar
kevin wood kevin wood is offline Offline
Posting Whiz in Training

$_COOKIES

  #1  
May 9th, 2008
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

<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'];
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2008
Location: Swindon, UK
Posts: 141
Reputation: xan is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 22
xan's Avatar
xan xan is offline Offline
Junior Poster

Re: $_COOKIES

  #2  
May 9th, 2008
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:
<?
// mt_rand(min value, max value)
$rand = mt_rand();
?>
Reply With Quote  
Join Date: Apr 2005
Location: New York state
Posts: 468
Reputation: ShawnCplus will become famous soon enough ShawnCplus will become famous soon enough 
Rep Power: 5
Solved Threads: 71
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Re: $_COOKIES

  #3  
May 9th, 2008
<input type="hidden" value="<?=$rand ?>" name="rand" />
The 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+*
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 4:33 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC