Hi, I am using the php get http command to get the url of the referring page. The problem is that it's including everything in the url like: http://www.domain.com/dir/subdir/page.html?id=whatever However I want just the domain like: http://www.domain.com Is there a way to extract just the domain from the complete URL? If so, please help me with a code. Thank you jeet
$url="http://www.domain.com/folder/page.php?id=12"; $pieces = explode("/", $url); echo $pieces[0]; echo $pieces[1]; echo $pieces[2]; echo $pieces[3]; PHP: This splits apart the url at each / http://uk2.php.net/explode
the above code will work but will return a few unwanted pieces this may be more useful $url="http://www.domain.com/folder/page.php?id=12"; $url = str_replace("http://", "", $url); $pieces = explode("/", $url); echo $pieces[0]; echo $pieces[1]; echo $pieces[2]; echo $pieces[3]; Code (markup): it just takes the first http:// out of the url so you wont endup with 2 blank array keys at the start
Oh also this means that you wont need to echo out the other pieces your URL will now be held in $piece[0];
Hi guys, Thanks so much for the help. Both your codes were exactly what I was looking for. Excluding the http:// part is very useful. Another thing, Can you guys please suggest some help on MY-SQL creation ? Something which a total newbe like me can follow... I looked at the w3schools help but wasn't able to follow a single word. Is there a website which takes me stepwise from creating a database, to creating tables, populating them, retrieving information from them, putting information in them when user fills a form on my site etc. Basically what I need to do is: Create a database with the following tables. username, password, email, user defined page, user input 1, user input 2, user input 3 All the fields except "username" can be modified later from the user's settings. Then I also want user input1, user input 2, user input 3 displayed on "user defined page" created on the fly. The username is the identifying field to get appropriate field from database. Although I am unaware of how to do all that. I know how to create a database using Cpanel. But am totally stupid if you ask me to create a table in it and then fill it. And again, So many thanks for both the codes above. Thank you jeet
Install phpmyadmin on your site and you will be able to do everything you ever want with databases. You will also learn stuff while you use it.
Hi, Thanks for those. I already have phpmyadmin on my server and it's time to explore it... Thank you guys. Best wishes jeet