I’m trying to pass data from flash to mysql through PHP, and I managed to do it, but then i needed to do the same thing again in another file, so i copied the code and pasted it and edited it. somehow…it didn’t work!! I’ve checked and checked… Pls help me. I’m desperate!!
Here’s the sickening code… =p
ACTION SCRIPT
on (release) {
//checks to see if there is something in both the name
//and password
//if (user == “” && pass == “”) {
//status = “One or more fields are empty please fill it in”;
//}
if (user == “” || pass == “” || hob == “” || sch == “”)
{
status = “Please fill in the required fields…”;
}
else
{
status = “Begin Login Process - Please Wait…”;
//if you changed the php file name, change it here to!!
myllv = new LoadVars();
mylreply = new LoadVars();
myllv.user = user1;
myllv.pass = pass1;
myllv.sch = sch;
myllv.hob = hob;
//myllv.action=“register”;
trace(myllv.user);
trace(myllv.pass);
trace(myllv.sch);
trace(myllv.hob);
trace(myllv.action);
myllv.sendAndLoad(“register.php”,mylreply,“POST”);
//myllv.sendAndLoad(“register.php”, mylreply, “GET”);
//trace(myllv.sendAndLoad(“register.php”, mylreply, “POST”));
mylreply.onLoad = function ()
{
this.val = Number(this.val);
//_root.userNo=Number(this.id);
if (this.val == 1)
{status=“You have registered successfully”;}
else if (this.val == 0)
{ status=“Username has already been used, Please choose another”;
user1="";
}
}
}
}
PHP
$user=$_POST[‘user’];
$pass=$_POST[‘pass’];
$hobby=$_POST[‘hob’];
$school=$_POST[‘sch’];
$j=0;
//connect to database
$file2= fopen(“rs2.txt”, “w”);
fwrite($file2, $user);
fclose($file2);
mysql_pconnect(“localhost”,“root”,"") or die (“didn’t connect to mysql”);
mysql_select_db(“elearning”) or die (“no database”);
//make query
$query = “SELECT * FROM user WHERE userName=’”.$user."’";
$result = mysql_query( $query ) or die (“didn’t query”);
//test
while($r=mysql_fetch_array($result))
{
//see if there’s an EXACT match
$num = mysql_num_rows( $result );
if ($num >0){
//print “status=You’re in&checklog=1&id=”.$j."";
print “val=0”;
//$file2= fopen(“rs2.txt”, “w”);
// fwrite($file2, $printer);
// fclose($file2);
} else {
$query=“INSERT INTO USER (userName,userPass,userSch,userHobby,userVal) values ($user,$pass,$school,$hobby,‘1’)”;
mysql_query( $query ) or die (“didn’t query”);
print “val=1”;
}
THANKS IN ADVANCE!