Using flash to communicate to a php file to connect to a db
Posted: Thu Mar 29, 2007 7:39 am
feyd | Please use
This code, im sure, is correct...
My PHP file contains the following...[/syntax]
Im not sure if the 'mysql.localhost' is correct, this should be my host name, which I am not sure of, but all other information is correct, database name, table name, and field names, but I just cant get it to do anything. PLEASE HELP, im clueless
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi guys, im new to all this PHP stuff, and am currently pulling my hair out with my problem.
I have a uni assignment that I am doing in Flash MX 2004, all run locally on a machine and not via the web. I have recently installed PHP, Apache, MySQL and Navcat MySQL free trial.
My database was created in Navcat MySQL, GUI based.
I have a simple form in Flash, with Username input and password input. The submit button has the ActionScript as follows...
[syntax="actionscript"]on (release, keyPress "<Enter>") {
if (user != "" && pass != "") {
status = "Wait...";
loadVariablesNum("newlogin.php", 0, "POST");
}
}My PHP file contains the following...[/syntax]
Code: Select all
<?
$user=$_POST['user'];
$pass=$_POST['pass'];
//connect to database
if ($user && $pass){
mysql_pconnect("mysql.localhost","root","") or die ("didn't connect to mysql");
mysql_select_db("tester") or die ("no database");
//make query
$query = "SELECT * FROM userpass WHERE username = '$user' AND password = '$pass'";
$result = mysql_query( $query ) or die ("didn't query");
//see if there's an EXACT match
$num = mysql_num_rows( $result );
if ($num == 1){
print "status=You're in&checklog=1";
} else {
print "status=Sorry, but your user name and password did not match a user name/password combination in our database. Usernames and passwords are entered in from a different file. Thank you for visiting test login script!!&checklog=2";
}
}
?>Im not sure if the 'mysql.localhost' is correct, this should be my host name, which I am not sure of, but all other information is correct, database name, table name, and field names, but I just cant get it to do anything. PLEASE HELP, im clueless
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]