Code: Select all
<?php
// ...
// ...
if (isset($_POST['submit'])) {
// ...
// Much more stuff in between: form authentication, initiating session values, etc.
// ...
session_start();
$_SESSION['last_name'] = $row[2];
$_SESSION['first_name'] = $row[1];
$_SESSION['user_id'] = $row[0];
$_SESSION['db_name'] = $db;
$_SESSION['project'] = $proj;
$_SESSION['url_prefix'] = $urlp;
mysql_close();
ob_end_clean();
header ("Location: http://" . $_SERVER['HTTP_HOST'] . "/subdir/landing_pg.php");
exit();
}
?>Code: Select all
<?php
ob_start();
session_start();
$db = $_SESSION['db_name'];
$proj = $_SESSION['project'];
$urlp = $_SESSION['url_prefix'];
require_once ('../dbc/db_connect.php');
?>.....
Now, our web server has a virtual hosting scheme which allows the insertion of a string directly before the domain name ($_SERVER['HTTP_HOST']) segment of the URL string such that...
http://domainname.com/subdir/landing_pg.php
...and...
http://whatever.domainname.com/subdir/landing_pg.php
... are both equivalent URLs to my landing page.
I can confirm that this works anywhere on the site when I manually type "whatever." into my browser's address bar directly before the domain.
But I'm trying to accomplish this through my login script. What I've come up with is to modify the header like so...
Code: Select all
header ("Location: http://" . $urlp . "." . $_SERVER['HTTP_HOST'] . "/subdir/landing_pg.php");http://project01.domainname.com/subdir/landing_pg.php
... but fail to connect with mysql again. It returns the default error from my connection script. I suppose I should include that script as well:
Code: Select all
<?php
DEFINE ('DB_USER', 'user01');
DEFINE ('DB_PASSWORD', 'password01');
DEFINE ('DB_HOST', 'mysql1.domainname.com');
DEFINE ('DB_NAME', $db);
$dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error() );
mysql_select_db (DB_NAME) OR die ('Unable to connect with your Project: ' . mysql_error());
?>"Unable to connect with your Project: No Database Selected"
What I infer from this is that there seems to be no problem with my DB_HOST, DB_USER or DB_PASSWORD, but that it is unable to parse DB_NAME as $db.
.....
Again, all was working fine before I added the complication of $urlp in the header() function on my login page.
Does concatenating a variable in the header seem like the right approach or is there a better way to create the URL I want? Unfortunately, I'm not able to access Apache or modify the environment variables on our server.
Jcart | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
(Thanks, Jcart, will do in the future. Blades)