witt Posted May 28, 2006 Share Posted May 28, 2006 I basically have a random number created that's sent via GET to another page. So basically page.php is sending rand(00,99) to page2.php and a link such as page2.php?rand=53 is given. On page2.php, the number 53 would have a certain meaning. Now what I want is so that if someone types in page2.php?rand=80, they are redirect to page.php instead of showing page2.php with nothing on it. I don't want to use a database by the way. Quote Link to comment https://forums.phpfreaks.com/topic/10635-validating-data-received-via-get/ Share on other sites More sharing options...
chai Posted May 28, 2006 Share Posted May 28, 2006 [!--quoteo(post=377776:date=May 28 2006, 04:01 AM:name=witt)--][div class=\'quotetop\']QUOTE(witt @ May 28 2006, 04:01 AM) [snapback]377776[/snapback][/div][div class=\'quotemain\'][!--quotec--]I basically have a random number created that's sent via GET to another page. So basically page.php is sending rand(00,99) to page2.php and a link such as page2.php?rand=53 is given. On page2.php, the number 53 would have a certain meaning. Now what I want is so that if someone types in page2.php?rand=80, they are redirect to page.php instead of showing page2.php with nothing on it. I don't want to use a database by the way.[/quote]If the purpose you want to do this checking is for security, you might want to create a session of user that is logged in your page.Assign a session id to user when they are logged in. And on every page, check whether session id is empty. If so, just redirect them to page.php.If you just want to make sure the databse have records with the eg.rand=53, on page2.php,simply write a sql to check on the db.If it return a value, proceed wit hyour proces, else redirect user to page.php Quote Link to comment https://forums.phpfreaks.com/topic/10635-validating-data-received-via-get/#findComment-39675 Share on other sites More sharing options...
AndyB Posted May 28, 2006 Share Posted May 28, 2006 I'm confused by your request. You want to choose a random number between 0 and 100 and some of those random numbers will be 'acceptable' to page2.php and others are unacceptable and cause a re-direction to page.phpIs that what you want? If so, retrieve the value of $rand from the $_GET array and check the passed value of $rand against an array of 'acceptable' numbers in page2.php. [a href=\"http://ca.php.net/manual/en/function.in-array.php\" target=\"_blank\"][b]in_array()[/b][/a] is the php function that'll do that for you. Quote Link to comment https://forums.phpfreaks.com/topic/10635-validating-data-received-via-get/#findComment-39694 Share on other sites More sharing options...
legohead6 Posted May 28, 2006 Share Posted May 28, 2006 [!--quoteo(post=377816:date=May 28 2006, 08:32 AM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ May 28 2006, 08:32 AM) [snapback]377816[/snapback][/div][div class=\'quotemain\'][!--quotec--]I'm confused by your request. You want to choose a random number between 0 and 100 and some of those random numbers will be 'acceptable' to page2.php and others are unacceptable and cause a re-direction to page.phpIs that what you want? If so, retrieve the value of $rand from the $_GET array and check the passed value of $rand against an array of 'acceptable' numbers in page2.php. [a href=\"http://ca.php.net/manual/en/function.in-array.php\" target=\"_blank\"][b]in_array()[/b][/a] is the php function that'll do that for you.[/quote]for page2[code]<?PHP$randomnumber=$_GET['number']if($randomnumber > 99){do whatever!}?>[/code]or you could go[code]if($randomnumber == 80){do this}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/10635-validating-data-received-via-get/#findComment-39711 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.