MDanz Posted June 28, 2011 Share Posted June 28, 2011 How do i use GET to get the username if the url is like this http://www.example.com/Username or is there another method rather than GET? Quote Link to comment https://forums.phpfreaks.com/topic/240628-user-profile-url-help/ Share on other sites More sharing options...
floridaflatlander Posted June 28, 2011 Share Posted June 28, 2011 I had to use htaccess and have a record with a field with the users name. When users register the db is searched for a simular name, if one already exist the user is given another name. Get searches for the name in my case. Quote Link to comment https://forums.phpfreaks.com/topic/240628-user-profile-url-help/#findComment-1235941 Share on other sites More sharing options...
fugix Posted June 28, 2011 Share Posted June 28, 2011 if you are talking about the actual text after http://www.example.com/Username, you can use a regular expression to match the text. $pattern = '/^http\:\/\/www\.[a-zA-Z0-9]+?\.com\/([a-zA-Z-0-9]+?)/'; Quote Link to comment https://forums.phpfreaks.com/topic/240628-user-profile-url-help/#findComment-1235942 Share on other sites More sharing options...
MDanz Posted June 28, 2011 Author Share Posted June 28, 2011 if you are talking about the actual text after http://www.example.com/Username, you can use a regular expression to match the text. $pattern = '/^http\:\/\/www\.[a-zA-Z0-9]+?\.com\/([a-zA-Z-0-9]+?)/'; so $pattern will get the Username from the url? Quote Link to comment https://forums.phpfreaks.com/topic/240628-user-profile-url-help/#findComment-1235946 Share on other sites More sharing options...
fugix Posted June 28, 2011 Share Posted June 28, 2011 i forgot to add the function that will actually use the pattern to grab the info path_info from your url.. $pattern = '/^http\:\/\/www\.[a-zA-Z0-9]+?\.com\/([a-zA-Z-0-9]+?)/'; $subject = 'http://www.example.com/Username'; preg_match($pattern,$subject,$matches); echo $matches[0]; where $matches[0] will contain your string data Quote Link to comment https://forums.phpfreaks.com/topic/240628-user-profile-url-help/#findComment-1235948 Share on other sites More sharing options...
Andy-H Posted June 28, 2011 Share Posted June 28, 2011 mod_rewrite Quote Link to comment https://forums.phpfreaks.com/topic/240628-user-profile-url-help/#findComment-1235950 Share on other sites More sharing options...
MDanz Posted June 29, 2011 Author Share Posted June 29, 2011 ok how do i get the page to display? i get this error Not Found The requested URL /test was not found on this server. for example the url is this http://www.example.com/$username Quote Link to comment https://forums.phpfreaks.com/topic/240628-user-profile-url-help/#findComment-1236289 Share on other sites More sharing options...
fugix Posted June 29, 2011 Share Posted June 29, 2011 why are you using a variable in you url? now im confused, can you explain further what you are trying to do Quote Link to comment https://forums.phpfreaks.com/topic/240628-user-profile-url-help/#findComment-1236303 Share on other sites More sharing options...
MDanz Posted June 29, 2011 Author Share Posted June 29, 2011 nvm i found a solution...basically i want a "pretty" url. thanks for the help anyway Quote Link to comment https://forums.phpfreaks.com/topic/240628-user-profile-url-help/#findComment-1236305 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.