evilgenius Posted March 13, 2007 Share Posted March 13, 2007 Hi, I'm quite new to PHP, and need help with making links for my new website. If there are two page 1- Index.php 2- contact.php What do I have to do to make them appear like, www.sitename.com/index.php?action=contact Thanks in advance for any help Quote Link to comment https://forums.phpfreaks.com/topic/42506-ques-for-making-links/ Share on other sites More sharing options...
Lumio Posted March 13, 2007 Share Posted March 13, 2007 everything after a questionmark ( ? ) is in the global $_GET-Array. So if you say: <?php if (isset($_GET['action'])) { //action set? if ($_GET['action'] == 'contact') { //does action has the value contact? require 'contact.php'; //bind contact.php } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/42506-ques-for-making-links/#findComment-206246 Share on other sites More sharing options...
aebstract Posted March 13, 2007 Share Posted March 13, 2007 Here is what I would do, and it allows you to add pages as you wish: <?php $action= $_GET['action']; if (isset($action)) { include "$action.php"; } else { include "home.php"; } ?> Make your link just as you stated, then it will set action from the url as a variable "$action". From that you include the correct page, if action isn't set, then it includes a home page. You can do a lot with this basis. Quote Link to comment https://forums.phpfreaks.com/topic/42506-ques-for-making-links/#findComment-206251 Share on other sites More sharing options...
evilgenius Posted March 13, 2007 Author Share Posted March 13, 2007 thanks Im quite new with php so can you please help me, how would I fit in the code with this <span class="style22">Comments and suggestion are welcome, please [b]Contact Us[/b] and lets know what you think of Funmasti. </span><br> with contact us. thanks Quote Link to comment https://forums.phpfreaks.com/topic/42506-ques-for-making-links/#findComment-206253 Share on other sites More sharing options...
Lumio Posted March 13, 2007 Share Posted March 13, 2007 Maybe it would be better to read some tutorials how to use php Quote Link to comment https://forums.phpfreaks.com/topic/42506-ques-for-making-links/#findComment-206259 Share on other sites More sharing options...
aebstract Posted March 13, 2007 Share Posted March 13, 2007 If you use the code I put for you, you would just simply do this: <span class="style22">Comments and suggestion are welcome, please [b]<a href="index.php?action=contact">Contact Us</a>[/b] and lets know what you think of Funmasti. </span><br> This will link you to - www.____.com/index.php?action=contact which will be your index page and include the contact wherever you place that bit of code. ( or any page you want to link like this, which is how you do templates ) Quote Link to comment https://forums.phpfreaks.com/topic/42506-ques-for-making-links/#findComment-206260 Share on other sites More sharing options...
evilgenius Posted March 13, 2007 Author Share Posted March 13, 2007 Maybe it would be better to read some tutorials how to use php Any specific one you can recommend? for this matter Quote Link to comment https://forums.phpfreaks.com/topic/42506-ques-for-making-links/#findComment-206299 Share on other sites More sharing options...
aebstract Posted March 13, 2007 Share Posted March 13, 2007 my post? Quote Link to comment https://forums.phpfreaks.com/topic/42506-ques-for-making-links/#findComment-206303 Share on other sites More sharing options...
Lumio Posted March 13, 2007 Share Posted March 13, 2007 www.php.net http://www.php.net/manual/en/ Quote Link to comment https://forums.phpfreaks.com/topic/42506-ques-for-making-links/#findComment-206305 Share on other sites More sharing options...
evilgenius Posted March 13, 2007 Author Share Posted March 13, 2007 www.php.net http://www.php.net/manual/en/ can you please be more specfic? Quote Link to comment https://forums.phpfreaks.com/topic/42506-ques-for-making-links/#findComment-206317 Share on other sites More sharing options...
aebstract Posted March 13, 2007 Share Posted March 13, 2007 I gave you 100% of the code needed to do exactly what you wanted. What are you tryin to get? Quote Link to comment https://forums.phpfreaks.com/topic/42506-ques-for-making-links/#findComment-206319 Share on other sites More sharing options...
evilgenius Posted March 13, 2007 Author Share Posted March 13, 2007 I gave you 100% of the code needed to do exactly what you wanted. What are you tryin to get? the code you gave (2nd time) is here Do i put the the first one bfore it. Its will then show contact in index, weird Im using DW8 Quote Link to comment https://forums.phpfreaks.com/topic/42506-ques-for-making-links/#findComment-206323 Share on other sites More sharing options...
aebstract Posted March 13, 2007 Share Posted March 13, 2007 What you said is that you want the contact page pulled in to the index page, when you click a link such as 'contact us'. You use the first code that I posted to pull the contact page in, if it is set in the url. The code pulls in home.php if nothing is set, if it is set, it pulls in whatever it is set to. You can easily make it work only if action = contact. <?php $action= $_GET['action']; if ($action == contact) { include "contact.php"; } ?> The link you have on your site now will cause this script to include contact.php wherever you place it. Quote Link to comment https://forums.phpfreaks.com/topic/42506-ques-for-making-links/#findComment-206372 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.