borden0108 Posted January 23, 2011 Share Posted January 23, 2011 Hi all i have been trying for 6 hours to write some code that will show a text box and the user puts in there id then it provides a link with the id in the middle of it so say the id is 111555 the link is http://example.com.au/data/users/111555/2011/1/1 i want the user to insert their id and do if the id 343034 the link is http://example.com.au/data/users/343034/2011/1/1 can any one give me the code to this i have gotten no where from tutorials please matt Link to comment https://forums.phpfreaks.com/topic/225380-textbox-coding-in-need-of-help/ Share on other sites More sharing options...
codefossa Posted January 23, 2011 Share Posted January 23, 2011 <?php $url1 = 'http://example.com.au/data/users/'; $url2 = '/2011/1/1'; if (isset($_GET['id'])) { echo $url1 . $_GET['id'] . $url2; } else { echo ' <form method="get" action=""> Enter ID <input type="text" name="id"> <input type="submit" value="Get URL"> </form>'; } ?> Link to comment https://forums.phpfreaks.com/topic/225380-textbox-coding-in-need-of-help/#findComment-1163891 Share on other sites More sharing options...
dragon_sa Posted January 23, 2011 Share Posted January 23, 2011 <?php if (isset($_POST['link']) && $_POST['link']!='') { $link=$_POST['link']; header("Location: http://www.example.com.au/data/users/$link/2011/1/1"); exit; } ?> Enter User ID:-<br/> <form method="post" action="" name="linkID'> <input type="text" name="link" size="20" /><br/> <input type="submit" name="submit" value="Submit Link" /> </form> really you should have some validation with that so users dont enter any one elses ID's but I dont really know what your doing with this. Link to comment https://forums.phpfreaks.com/topic/225380-textbox-coding-in-need-of-help/#findComment-1163893 Share on other sites More sharing options...
codefossa Posted January 23, 2011 Share Posted January 23, 2011 really you should have some validation with that so users dont enter any one elses ID's but I dont really know what your doing with this. I'm sure now that he has the basic set up he'll alter it to fit his needs. Link to comment https://forums.phpfreaks.com/topic/225380-textbox-coding-in-need-of-help/#findComment-1163894 Share on other sites More sharing options...
borden0108 Posted January 23, 2011 Author Share Posted January 23, 2011 sorry but i trailed it and put the id in but it did not return a link i trialed php in a .html doc so so sorry can you possibly attach a html file with a working code so sorry :'( Link to comment https://forums.phpfreaks.com/topic/225380-textbox-coding-in-need-of-help/#findComment-1163896 Share on other sites More sharing options...
dragon_sa Posted January 23, 2011 Share Posted January 23, 2011 you have to save the page as a .php file for example index.php otherwise your php wont be initialized and will not work, you cant use php code on a page that ends with .html it has to be .php Link to comment https://forums.phpfreaks.com/topic/225380-textbox-coding-in-need-of-help/#findComment-1163897 Share on other sites More sharing options...
borden0108 Posted January 23, 2011 Author Share Posted January 23, 2011 but then safari will not read it it just shows the source code Link to comment https://forums.phpfreaks.com/topic/225380-textbox-coding-in-need-of-help/#findComment-1163901 Share on other sites More sharing options...
dragon_sa Posted January 23, 2011 Share Posted January 23, 2011 php code needs to be uploaded to your server you cannot preview it in your browser without uploading it to your server first, php is read by the server and then outputs html code to the users browser based on the processed code, if yo just open a php page directly on your computer then it will only show the source code as no server has processed it. Once you upload it to your web server and then look at the page you will only see the form the code outputs and not the php. Link to comment https://forums.phpfreaks.com/topic/225380-textbox-coding-in-need-of-help/#findComment-1163904 Share on other sites More sharing options...
borden0108 Posted January 24, 2011 Author Share Posted January 24, 2011 i uploaded it and it only downloads it HELP Link to comment https://forums.phpfreaks.com/topic/225380-textbox-coding-in-need-of-help/#findComment-1164313 Share on other sites More sharing options...
dragon_sa Posted January 24, 2011 Share Posted January 24, 2011 Did you save it as a php file first? Also does the server you uploaded to support php? You need to show us your code you have uploaded as we cant help with anything if we cant see what you have done. Link to comment https://forums.phpfreaks.com/topic/225380-textbox-coding-in-need-of-help/#findComment-1164315 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.