true3000 Posted February 5, 2011 Share Posted February 5, 2011 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"); ?> Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted February 5, 2011 Share Posted February 5, 2011 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. 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.