Jump to content

Need help...please!


true3000

Recommended Posts

Alright, so here's the deal...and yes, I have searched high and low and haven't been able to find the solution I am looking for.

 

I want to create a subdomain such as texas.mydomain.com and when someone visits that site they get redirected to my main domain BUT with a welcome message such as "Hi Texans, welcome to mydomain.com"...

 

Now when someone enters just mydomain.com it would read as something generic like..."Hi there"...

 

Anybody know what the appropriate code would be or at least point me in the right direction?

 

EDIT:

 

I was able to come up with the following but it causes the site to return blank...

<?
$states = array(
          "tx" => "Texan",
          "ak" => "Alaskan"
          );

// If the "s" (state) parameter isn't set or the state code doesn't exist in the array (user tampered), show generic message
if ((!isset($_GET['s'])) || (!array_key_exists($_GET['s'], $states))) {
     echo "Insert generic welcome message."
} else {
     $key = $_GET['s'];
     echo "Welcome, " . $states[$key] . "." // Shows "Welcome, Texan." etc.
}
?>

 

the subdomain is redirected using:

<?
// Redirects user to main site, with parameter "s" (state) as "tx" (Texas)
header("Location: http://www.mydomain.com/?s=tx");
?>

 

 

 

Link to comment
Share on other sites

the reason the first code snippet returns blank is a missing semi-colon causing a failure to parse the code. parse errors are the most critical errors to know about in PHP. you should ensure that your error reporting is set in php.ini to display errors, especially parse errors, but all errors, notices and warnings is the best policy.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.