kev wood Posted May 9, 2008 Share Posted May 9, 2008 i have tried using session_start() but this does not like some of the code that has been used within the page i need to pass the variable from. I cannot use $_POST as the variable is on a page held with an iframe, and i cannot use $_GET as also the variable is in an iframe i have lookd at other ways but i am not to sure about them as i have never used any other ways to send variables. Ths variable i want to send is a random number that is generated from the php rand function. the number is used to attach to a image so that the image cannot be displayed from the cache due to the image changing but not the name it is held under. I have lookd at cookies but dont know if this is the best way to go about this because i know cookies are not accepted everywhere. If someone could point me in the direction of another way to pass the variable to the next page i would greatfull as this is giving me a headache. Link to comment https://forums.phpfreaks.com/topic/104847-passing-veriables-to-new-page/ Share on other sites More sharing options...
johnsmith153 Posted May 9, 2008 Share Posted May 9, 2008 Can not be a problem if generating random number in php. Would understand if you tried generating random number client side and then did not post back to server. OPTION A: ------------ 1. Create php random number $randomnumber 2. <?php session_start(); $_SESSION['uniqueid'] = $randomnumber; 3. In future, when you wanto display: <?php echo $_SESSION['uniqueid']; ?> (ensure you have used session_start on the display page also) OPTION B: ----------- Or you could just attach it to the url if you did not want to use sessions: 1. Create php random number $randomnumber 2. <a href="nextpage.php?rndnumber=<?php echo $randomnumber; ?>">Click For Next Page</a> 3. On the next page, use echo $_GET['rndnumber'] to get it from the url and display. Link to comment https://forums.phpfreaks.com/topic/104847-passing-veriables-to-new-page/#findComment-536676 Share on other sites More sharing options...
johnsmith153 Posted May 9, 2008 Share Posted May 9, 2008 [/url] Not sure why the end of my code was changed. Just make sure it is < / a > (without spaces) not [/url] Link to comment https://forums.phpfreaks.com/topic/104847-passing-veriables-to-new-page/#findComment-536677 Share on other sites More sharing options...
kev wood Posted May 9, 2008 Author Share Posted May 9, 2008 i have tried using the session_start () but as the numbr is being generated in an iframe i dont think it is possible to append the variable to the hyperlink as this is on the page that the i frmae is held on. I will explain my problem in more detail sorry if it goes on a bit. I have a page were the user can enter some text and upload an image to go with the text. the image upload section is the iframe, on that page it uses a submit button to upload the images. The random number is added to the image file here, the reason for this is because the images are stored in a variable name and displayed using this. This created a problem with the images getting cached. If the user comes back to upload a new image with the same file type it loads the image from the cache which is the old one. When i tried to use the session_start function it gave me loads of errors with the image resizing code, saying that some of the variables used were not valid image resources. If i was to use the get function then there would have to be a hyperlink on the upload frame so that it could be appended to that there which there is not. so iam now left scratching my head as i do not know if cookies will work as not all servers/browsers except these and they can also be manipulated by the user. Link to comment https://forums.phpfreaks.com/topic/104847-passing-veriables-to-new-page/#findComment-536700 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.