xstevex Posted December 30, 2007 Share Posted December 30, 2007 Hi, I'm trying to get this statement to work: <?php if ($path = 'http://www.mysite/directory1/') { ?> <!--nothing--> <?php } else { ?> <?php print '<h2'. ($tabs ? ' class="with-tabs"' : '') .'>'. $title .'</h2>'; ?> <?php } ?> The problem I think is with the $path bit. I want the second bit to show up on every page except the $path pages. I've tried $url and others but haven't found the right way to do it. My php knowledge is very basic. Thanks, Steve. Quote Link to comment https://forums.phpfreaks.com/topic/83677-if-path-equals-help/ Share on other sites More sharing options...
cooldude832 Posted December 30, 2007 Share Posted December 30, 2007 where u finding these variibles $path, $url??? Quote Link to comment https://forums.phpfreaks.com/topic/83677-if-path-equals-help/#findComment-425692 Share on other sites More sharing options...
xstevex Posted December 30, 2007 Author Share Posted December 30, 2007 Hi, I've found them searching forums and seeing similar code to what I want to do and trying to modify and use it. Steve. Quote Link to comment https://forums.phpfreaks.com/topic/83677-if-path-equals-help/#findComment-425699 Share on other sites More sharing options...
cooldude832 Posted December 30, 2007 Share Posted December 30, 2007 well variables don't magically appear to what you think thye should be you have to define em Quote Link to comment https://forums.phpfreaks.com/topic/83677-if-path-equals-help/#findComment-425700 Share on other sites More sharing options...
xstevex Posted December 30, 2007 Author Share Posted December 30, 2007 Is there a way to do it using the url? I think this would be simplest. I don't need to do it this other way. Quote Link to comment https://forums.phpfreaks.com/topic/83677-if-path-equals-help/#findComment-425710 Share on other sites More sharing options...
cooldude832 Posted December 30, 2007 Share Posted December 30, 2007 go to php.net and look up the $_SERVER variable it has some info you might be able to use Quote Link to comment https://forums.phpfreaks.com/topic/83677-if-path-equals-help/#findComment-425712 Share on other sites More sharing options...
xstevex Posted December 30, 2007 Author Share Posted December 30, 2007 I've seen many different things to try and gotten many errors. My php knowledge is basic so if you could give me an example of the syntax that would be good. Quote Link to comment https://forums.phpfreaks.com/topic/83677-if-path-equals-help/#findComment-425730 Share on other sites More sharing options...
cooldude832 Posted December 30, 2007 Share Posted December 30, 2007 did u look up the $_SERVER var and find something useful? Quote Link to comment https://forums.phpfreaks.com/topic/83677-if-path-equals-help/#findComment-425731 Share on other sites More sharing options...
Sesquipedalian Posted December 30, 2007 Share Posted December 30, 2007 that code made no sense at all... But uh.. the if statement would be: if ($_SERVER["PHP_SELF"] == 'http://www.mysite/directory1/') {} but really.. the code won't work by the way you wrote it.. even if you change that... Quote Link to comment https://forums.phpfreaks.com/topic/83677-if-path-equals-help/#findComment-425734 Share on other sites More sharing options...
xstevex Posted December 30, 2007 Author Share Posted December 30, 2007 Ok, I'm sorry. Essentially all I'm trying to do is make a statement that does: if it is in URLx, the thing doesn't show, but if it is in any other URL, the thing does show. I've just learnt how to define variables now so I can define a variable if needed. Or, "if not in URLx, show the thing" would be good too. Quote Link to comment https://forums.phpfreaks.com/topic/83677-if-path-equals-help/#findComment-425738 Share on other sites More sharing options...
redarrow Posted December 30, 2007 Share Posted December 30, 2007 just nocked this up try it quite good lol.... i wrote this so you get the jeft ok mate..... type anythink what in the array get a result........... <?php $x=array('http://www.google.com','http://www.msn.com','http://www.yahho.com'); if($_POST['submit']){ $url=$_POST['url']; if(in_array("$url",$x)){ echo " congratulations goto <a href='$url'>>>here<<<a/>"; exit; }else{ echo "sorry we have no $url of this type please try agin <a href='".$_SERVER['PHP_SELF']."'>>>here<<<a/>"; exit; } } echo"<center> <form method='POST' action=' '> <br><br> please provide your url <br> The name off the website<br> example http://www.google.com! <br><br> <input type='text' name='url'> <br><br> <input type='submit' name='submit' vlaue='Send'> </form> </center>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/83677-if-path-equals-help/#findComment-425755 Share on other sites More sharing options...
xstevex Posted December 30, 2007 Author Share Posted December 30, 2007 Thanks Red arrow and others, It will take me some time to test this out. Steve Quote Link to comment https://forums.phpfreaks.com/topic/83677-if-path-equals-help/#findComment-425762 Share on other sites More sharing options...
xstevex Posted January 2, 2008 Author Share Posted January 2, 2008 Thanks a lot for the advice. I tried many solutions, really I did, but in the end I resorted to just removing the titles from my database manually, which did the trick. Quote Link to comment https://forums.phpfreaks.com/topic/83677-if-path-equals-help/#findComment-427858 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.