PDA

View Full Version : login :: load url from database


fauxmanchu
03-22-2008, 05:51 PM
first :: apologies for my lack of skillz.

i have a client login that needs to load the appropriate website based on their login information. the client login works properly and my "members.php" page loads, but . . .

problem :: my database contains "user", "pass" and "link". once the user logs in, i need the "link" (actual web page based on "link") to load in a new window - based on login information.

here's my flash code (works fine)::
var lvSend:LoadVars = new LoadVars();
var lvReceive:LoadVars = new LoadVars();

tError.autoSize = "right";

mcLogin.onRelease = function() {
lvSend.user = tUser.text;
lvSend.pass = tPass.text;
lvSend.sendAndLoad("logincheck.php", lvReceive, "POST");
};

lvReceive.onLoad = function(success:Boolean) {
if (success) {
if (this.login == "success") {
getURL("members.php","_blank","POST");
} else {
tError.text = "I'm sorry you did not enter valid login details";
}
} else {
trace("no reponse from server");
}
};

__________________________________________
here's my dbDetails.php code (works fine)::
<?php
//mysql details
$remote = true; // change this to true when uploading online, or keep false when testing locally

if($remote){
//your online mySQL database details
$host = "server";
$dbusername = "username";
$dbpassword = "password";
$db = "database";
$table="auth";
}


//database connection - you do not need to change the following
$conn = mysql_connect($host, $dbusername, $dbpassword) or die("could not connect to server");
$select_db = mysql_select_db($db,$conn);
?>

________________________________________
here's the logincheck.php code (works fine) ::
<?php
session_start();
$user = $_POST['user'];
$pass = $_POST['pass'];

//mysqldetails
include("dbDetails.php");

$query = "SELECT * FROM `$db`.`$table` WHERE `user` ='".$user."' AND `pass` = '".$pass."'";

$result = mysql_query($query,$conn);
$row = mysql_num_rows($result);


if($row > 0){
$_SESSION['loggedIn'] = true;
echo 'login=success';
}else{
echo 'login=failure';
}

?>

_________________________________________
***here's the members.php code (not working properly) ::
this code simply reflects an echo of the "link" and that's not even working properly, but ultimately i want to load "link" in a new window not echo.
<?php
session_start();

$user = $_POST['user'];
$pass = $_POST['pass'];

//mysqldetails
include("dbDetails.php");

//check if the loggedIn session has been really set so that noone can access this page directly. If it is not set send him to login page
if(!isset($_SESSION['loggedIn'])){
header("Location: login.html");
exit();
}

//return corresponding link from database
else{

$query = "SELECT * FROM `$db`.`$table` WHERE `user` ='".$user."' AND `pass` = '".$pass."'";

$result = mysql_query($query,$conn);

while($row=mysql_fetch_array($result)){
echo $row['link'];
}
}
mysql_close();

?>



MANY MANY THANKS IN ADVANCE FOR ANY HELP!