CloudSex13 Posted April 15, 2009 Share Posted April 15, 2009 Hi, thanks for reading. I have a scenario... I have a page called page.php. On that page holds the sentence "This is some text." When I click a link from that page that links to page.php?task=hello, the text displays "Hi. Thanks for clicking me." but it also displays "This is some text." Is there anyway to configure and/or prevent "This is some text." from displaying? Quote Link to comment https://forums.phpfreaks.com/topic/154242-solved-stop-page-from-displaying/ Share on other sites More sharing options...
laffin Posted April 15, 2009 Share Posted April 15, 2009 if statements with yer task as the expression, when task is not isset, than diplay 'This is some text' Quote Link to comment https://forums.phpfreaks.com/topic/154242-solved-stop-page-from-displaying/#findComment-810867 Share on other sites More sharing options...
Maq Posted April 15, 2009 Share Posted April 15, 2009 Code please? Quote Link to comment https://forums.phpfreaks.com/topic/154242-solved-stop-page-from-displaying/#findComment-810869 Share on other sites More sharing options...
Mchl Posted April 15, 2009 Share Posted April 15, 2009 Yes there is Use if and isset to check it $_GET['task'] is set (and if it is, don't display 'This is some text') Quote Link to comment https://forums.phpfreaks.com/topic/154242-solved-stop-page-from-displaying/#findComment-810872 Share on other sites More sharing options...
CloudSex13 Posted April 15, 2009 Author Share Posted April 15, 2009 The following is the code: <?php include('config.php'); if (isset($_GET['task'])) { $task = ($_GET['task']); if ($task == "hello") { $task = hello(); } else { echo ""; } function hello() { return " Hi. Thanks for clicking me."; } ?> <html> <head> <title>Test</title> <link rel=stylesheet type=text/css href=layout.css> </head> <body> <div id=container> <a href="page.php?task=hello">Hello</a> <br><br> This is some text. </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/154242-solved-stop-page-from-displaying/#findComment-810879 Share on other sites More sharing options...
CloudSex13 Posted April 15, 2009 Author Share Posted April 15, 2009 "This is some text" is displayed on page.php, though. Quote Link to comment https://forums.phpfreaks.com/topic/154242-solved-stop-page-from-displaying/#findComment-810880 Share on other sites More sharing options...
Maq Posted April 15, 2009 Share Posted April 15, 2009 There's nothing telling the text not to output. Every time that page is called "This is some text", is going to display. Quote Link to comment https://forums.phpfreaks.com/topic/154242-solved-stop-page-from-displaying/#findComment-810889 Share on other sites More sharing options...
CloudSex13 Posted April 15, 2009 Author Share Posted April 15, 2009 Thanks Maq. So my only option would be to make a separate function called welcome() or something similar? Quote Link to comment https://forums.phpfreaks.com/topic/154242-solved-stop-page-from-displaying/#findComment-810891 Share on other sites More sharing options...
Maq Posted April 15, 2009 Share Posted April 15, 2009 Get rid of the, "This is some text", and replace it with $body. There's no need for a function here, but I assume you're going to use this for a bigger script so I'll leave it. if ($_GET['task'] == "hello") { $body = hello(); } else { $body = "This is some text"; } function hello() { return " Hi. Thanks for clicking me."; } Quote Link to comment https://forums.phpfreaks.com/topic/154242-solved-stop-page-from-displaying/#findComment-810896 Share on other sites More sharing options...
CloudSex13 Posted April 15, 2009 Author Share Posted April 15, 2009 Yeah, just planning ahead, and learning. Thanks Maq for this - I greatly appreciate it. Quote Link to comment https://forums.phpfreaks.com/topic/154242-solved-stop-page-from-displaying/#findComment-810904 Share on other sites More sharing options...
Maq Posted April 15, 2009 Share Posted April 15, 2009 Yeah, just planning ahead, and learning. Thanks Maq for this - I greatly appreciate it. Sure. This will work well for your small example, but if you were to write a bigger script or application there could be a better solution depending on certain factors. You should always think ahead and create a good model and design for your application. Quote Link to comment https://forums.phpfreaks.com/topic/154242-solved-stop-page-from-displaying/#findComment-810913 Share on other sites More sharing options...
CloudSex13 Posted April 15, 2009 Author Share Posted April 15, 2009 Better solutions, such as switch cases? I hear you, though. Quote Link to comment https://forums.phpfreaks.com/topic/154242-solved-stop-page-from-displaying/#findComment-810915 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.