quelle Posted December 22, 2010 Share Posted December 22, 2010 if i got some homepage named index.php and got a $_GET function which calls index.php?strana=2, how do i define so my index.php or just www.example.com/folder/ is same like index.php?strana. Cuz Ive got 2 forms on my website and when i put index.php?strana - i get the first one, when i put index.php?strana=2 - i get the second one but when i put index.php only or blank as i said above im still getting second form Quote Link to comment Share on other sites More sharing options...
Rifts Posted December 22, 2010 Share Posted December 22, 2010 you need to post your code its probably because you have something like if strana = 1 { } else { } so its showing the second one for everything except if it equals 1 Quote Link to comment Share on other sites More sharing options...
quelle Posted December 22, 2010 Author Share Posted December 22, 2010 ive got something like this if (isset($_GET['strana']) && $_GET['strana'] == ""){ //and here comes the form code 1 ... } //then i got else, form code 2. Since i wanna show only 2 forms i can just use if, else else{ ... } Quote Link to comment Share on other sites More sharing options...
spaceman12 Posted December 22, 2010 Share Posted December 22, 2010 <?php if (isset($_GET['your_variable']))?> <a href=index.php?strana=<?php echo $_GET['your_variable']; ?> >your link</a> Quote Link to comment Share on other sites More sharing options...
quelle Posted December 22, 2010 Author Share Posted December 22, 2010 Obviously u didnt get what i mean, that variable will give FALSE because i use just for ex. localhost/fuckme/index.php so it would still show my second form ... I want some code that will check for me do i use index.php or index.php?strana=(no matther what number) Quote Link to comment Share on other sites More sharing options...
spaceman12 Posted December 22, 2010 Share Posted December 22, 2010 if u r working on to pass variables from pages to pages, u got to always use the suffix ? at the end just after .php no matter the directory ur file is placed in. For instance, /home/strana/index.php?strana= like this. When $_GET is not set n u want to execute another function, use !isset() Quote Link to comment Share on other sites More sharing options...
The Letter E Posted December 22, 2010 Share Posted December 22, 2010 ive got something like this if (isset($_GET['strana']) && $_GET['strana'] == ""){ //and here comes the form code 1 ... } //then i got else, form code 2. Since i wanna show only 2 forms i can just use if, else else{ ... } Try This: ) $strana = $_GET['strana']; if(isset($strana){ if ($strana == "2"){ //My code for ?strana=2 } else{ //My code for ?strana } } else{ //My code when strana is not set } Quote Link to comment Share on other sites More sharing options...
The Letter E Posted December 22, 2010 Share Posted December 22, 2010 Also, assuming in the future you had more values for strana you could use: $strana = $_GET['strana']; if(isset($strana){ if ($strana == "2"){ //My code for ?strana=2 } elseif($strana == "3"){ //My code for ?strana=3 } else{ //My code for ?strana } } else{ //My code when strana is not set } Quote Link to comment Share on other sites More sharing options...
quelle Posted December 24, 2010 Author Share Posted December 24, 2010 $strana = $_GET['strana']; if(isset($strana){ if ($strana == "2"){ //My code for ?strana=2 } elseif($strana == "3"){ //My code for ?strana=3 } else{ //My code for ?strana } } else{ //My code when strana is not set } how would i define here that index.php is same as index.php?strana? Quote Link to comment Share on other sites More sharing options...
The Letter E Posted December 24, 2010 Share Posted December 24, 2010 $strana = $_GET['strana']; if(isset($strana){ if ($strana == "2"){ //My code for ?strana=2 } elseif($strana == "3"){ //My code for ?strana=3 } else{ //My code for ?strana } } else{ //My code when strana is not set } how would i define here that index.php is same as index.php?strana? Like this: $strana = $_GET['strana']; if(isset($strana){ if ($strana == "2"){ //index.php?strana=2 } elseif($strana == "3"){ //index.php?strana=3 } else{ //index.php } } else{ //index.php } Quote Link to comment 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.