kurtis Posted August 8, 2006 Share Posted August 8, 2006 hi,does anyone know how i can get what is after the slash in a URL?im wanting to edit my 404 error page so if people go to blabla.con/username it will search the database for the username and if its there save all the needed info to a session and forward the reader to profile.php and display the info. All i need is how to get the URL thing i can do the rest but obviously if someone allready has the code somewhere i wouldnt mind them copying it all in ;DAlso if anyone knows a easyer way to do this then sugestions are welcome :)thanks Quote Link to comment Share on other sites More sharing options...
SharkBait Posted August 8, 2006 Share Posted August 8, 2006 So you're looking for what is after the forward slashes? Could try exploding the URL[code]<?php$url = array();// Can automate it with a $_SERVER['PHP_SELF'] too if you wish// but this example is manually entered$url = explode("/", "blabla.com/username")// 2nd place is the username would be stored$username = $url[1];?>[/code] Quote Link to comment Share on other sites More sharing options...
corbin Posted August 8, 2006 Share Posted August 8, 2006 I did something similar to that when i was making a script a few weeks back... Only bad thing is that the servers error logs become use less when it comes to page not found... Quote Link to comment Share on other sites More sharing options...
kurtis Posted August 8, 2006 Author Share Posted August 8, 2006 would this idea work:[code]<?php$url = $_SERVER['REQUEST_URI'];$user_check = "SELECT * FROM users WHERE username='$url'";$result_user_check = mysql_query($user_check);$userfound = mysql_num_rows($result_user_check); if ($userfound < 1) { $error = "user or directory was not found.";} else { $user_info = mysql_fetch_array(mysql_query($user_check)); $_SESSION['username1'] = $user_info['username']//rest of the sessions...........?>[/code] 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.