timmah1 Posted May 30, 2008 Share Posted May 30, 2008 I have a form that inserts domain names into a database field. The domain name could be simple (http://www.test.com/hi/) or complex (http://cgi.ljx.com/cgi-bin/memo/show?articleid=hunton,23) When I pull this information from the database, how can I just show the domain (http://www.test.com or http://www.ljx.com)? Thanks in advance! Quote Link to comment Share on other sites More sharing options...
thebadbad Posted May 30, 2008 Share Posted May 30, 2008 <?php $url = 'http://cgi.ljx.com/cgi-bin/memo/show?articleid=hunton,23'; $url_info = parse_url($url); echo $url_info['scheme'], '://', $url_info['host']; // http://cgi.ljx.com ?> Quote Link to comment Share on other sites More sharing options...
paulman888888 Posted May 30, 2008 Share Posted May 30, 2008 <?php //chanhe domainname to the form data you want $url = echo $_POST['domainname']; $url_info = parse_url($url); echo $url_info['scheme'], '://', $url_info['host']; // Getting form data ?> Quote Link to comment Share on other sites More sharing options...
timmah1 Posted May 30, 2008 Author Share Posted May 30, 2008 Exactly what I was trying to do thebadbad. I'm know starting to understand parse_url after seeing a working example Thank you. 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.