WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : url,display url,complete url,fetch url,grab
Categories : HTML and PHP, HTML, PHP Update Picture
Espen Holje
Date : May 02nd 2000
Grade : 4 of 5 (graded 2 times)
Viewed : 7032
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Espen Holje
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

In order to grad the complete URL as typed in the browser (http://www.company.com), you
need to have a script or HTML-file forward you to your PHP-script and passing the URL as a
parameter using JavaScript.

The solution consists to two files: INDEX.HTM and ACTION.PHP3. Index.HTM forwards the user
to a PHP-script (ACTION.PHP3) with the original URL passed as a parameter.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
<SCRIPT language="JavaScript">
function openmain() {
document.location = 'action.php3?url='+document.location;
}
</SCRIPT>
</head>
<body onload ="openmain();">
</body>
</html>

In ACTION.PHP3 we can act upon which URL the user typed. For example:

...
<?


// returns hostname from url (hostname in "www.hostname.com")
// returns value "localhost" if run from a local webserver (developement server)
function returnhostname($p_url)
{
//http://www.hostname.com/something
$tmp = str_replace("http://","",$p_url);

//www.hostname.com/something
$arrTmp = explode ("/",$tmp);

//$arrTmp[0] = www.hostname.com
$arrTmp2 = explode (".",$arrTmp[0]);

$comp = strcmp(strtolower($arrTmp2[0]),"www");
if ( $comp == 0 ) {
return (strtolower($arrTmp2[1]));
} else {
return (strtolower($arrTmp2[0]));
}
}

//check if URL is set
if (!isset($url)) {
//set fallback URL in case user opened PHP-script before INDEX.HTM
$url = "www.sullandbil.no";
}

$company = returnhostname ($url);
if ($company != "sullandbil") {
die ("The website for the company requested is under construction<br>");
}


?>



Display Slashdot headers on your own site
Categories : HTML and PHP, HTML, PHP
webcam cam view image ispy browser independant
Categories : Graphics, HTML, HTML and PHP, PHP
How to preset a text string in a textarea input field
Categories : HTML, HTML and PHP, PHP, Beginner Guides
Automatic generation of HTML code for a table. OO interface. Can define colspan, rowspan, table style, cell style, and data style. Simple, but effective.
Categories : PHP, PHP Classes, HTML, HTML and PHP
This script shows you the 7th latest php items from the mailing list archive on zend.com
Categories : HTML, HTML and PHP, HTTP, PHP
GonxTabs : Create elegant HTML tabs based interface
Categories : Navigation, HTML, HTML and PHP, PHP
class formHTML build your HTML Forms from PHP
Categories : PHP, PHP Classes, HTML and PHP, HTML
Snipe.Net's Web Design Color Scheme Previewer- Allows uses to input hex codes for their text, background, and link colors, and preview the color scheme with their background image. Example: http://www.snipe.net/tech/snipeschool/hex.php3
Categories : PHP, HTML and PHP, General, Graphics, HTML
Query2Report : Generating Html, Pdf and Csv Reports from SQL Query
Categories : PHP, PHP, HTML, PDF, Excel
How to use regular expressions to get the list of links from an HTML page
Categories : PHP, Regexps, HTML, HTML and PHP
Real simple example of removing HTML tags from text then changing \n (new line) to <br>. Could be used in a forum for instance.
Categories : HTML, PHP, HTML and PHP, Beginner Guides
PHP3: Formmail. Just a cgi formmail, but than in PHP. It is easy to use!
Categories : HTML and PHP, Email, PHP, Perl, HTML and PHP
Popup Menu 0.5, popup, select, html, state-maintaing
Categories : HTML, PHP, HTML and PHP
A simple class with some HTML output functions that would come in handy for consistent page layout etc.
Categories : PHP, PHP Classes, HTML and PHP, HTML, Navigation
a function that builds an HTML select list from any mysql table.
Categories : PHP, MySQL, HTML and PHP