PDA

View Full Version : Simple Password MSSQL


nathanleyton
07-07-2003, 04:30 PM
Why is flash not sending the varibles to PHP.

I have 2 input text boxes on Level0 with 2 variable names
usernamesend
passwordsend

I have a button with this on it

on (release, keyPress "<Enter>") {
if (usernamesend == null) {
message = "Please Insert Username & Password";
gotoAndPlay(_currentframe-1);
} else {
loadVariablesNum("http://localhost/OnlineStats/login.php", 0, "POST");
message = "testing";
}
}


the message goes to testing... it retries data from my PHP script but it hasn't sent the variables I know this becuase PHP is sending back messages to my message variable to tell what is happening and when.

Ill post my PHP just so you can see.


<?php

$myServer = "MYSERVER";
$myUser = "MYUSER";
$myPass = "MYPASSWORD";
$myDB = "MYDB";



$s = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");

$d = mssql_select_db($myDB, $s)
or die("Couldn't open database $myDB");

$query = "SELECT * FROM OnlineStatsLogin WHERE username = '$usernamesend'";
$result = mssql_query($query);
$numRows = mssql_num_rows($result);

if ($numRows == null){
print "&message=no rows found";}

else
{$username = mssql_result($result,0,"username");
$password = mssql_result($result,0,"password");

if ($password == $passwordsend and $username == $usernamesend)
{$message = 'Authenticated';}
else
{$message = 'Failed';}

if ($passwordsend == null)
{$message = 'please insert username and password';}
print "&message=$message";
}

?>


Thanks for reading..

NAthan

nathanleyton
07-08-2003, 12:55 PM
<?php

$myServer = "INHOUSE,1433";
$myUser = "sa";
$myPass = "respond";
$myDB = "Collator";
$usernamesend = $_REQUEST['usernamesend'];
$passwordsend = $_REQUEST['passwordsend'];

$s = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");

$d = mssql_select_db($myDB, $s)
or die("Couldn't open database $myDB");

$query = "SELECT * FROM OnlineStatsLogin WHERE username = '$usernamesend'";
$result = mssql_query($query);
$numRows = mssql_num_rows($result);


if ($numRows == null){
print "&message=Failed";}

else
{$username = mssql_result($result,0,"username");
$password = mssql_result($result,0,"password");

if ($password == $passwordsend and $username == $usernamesend)
{$message = 'Authenticated';}
else
{$message = 'Failed';}

if ($passwordsend == null)
{$message = 'Please insert Username and Password';}
print "&message=$message";
}


?>


The new PHP has register_globals off in the php.ini file. this is security issue..

My code above shows how you can get the variables in to the script using $_REQUEST predefined global.....

Hope this comes in handy to people as it did for me.