Ok, i created a user login for my site using PHP and a MySQL database. I developed it from Freddythunder’s tutorial on this site. It works perfectly now, after tweaking it a bit…but it’s currently set up where you have to add users through a php file COLOR=Olive[/COLOR]. i want to be able to add users from an “admin” page in my Flash site…so i removed all the HTML and form tags from [COLOR=Olive]usercheck.php[/COLOR] and saved it as [COLOR=Olive]adduser.php[/COLOR] and set up my flash file exactly as the HTML elements in [COLOR=Olive]usercheck.php[/COLOR]. I figured that it would work the same way…but for some reason…it doesn’t work at all.
[COLOR=Olive]INCLUDED FILES IN ATTACHED .ZIP:
addNewUsers.fla (MX2004 format)
adduser.php
usercheck.php[/COLOR]
I have NO knowledge of php so i can’t really figure out why it doesn’t work properly. All the variables are set up correctly in the flash file (i think)…
here is what the addusers.php file looks like in case someone can spot something obviously wrong in it:
<?PHP
$newUser = $_POST['newUser'];
$passOne = $_POST['passOne'];
$passTwo = $_POST['passTwo'];
//these variables are set to 3 corresponding input boxes in flash file
//
if ($passOne == $passTwo) {
$newPass = $passOne;
//
} else {
print "response=Passwords mismatched";
//response is a dynamic text box's variable in flash file
}
//
if (($REQUEST_METHOD=='POST')) {
for(reset($HTTP_POST_VARS);
$key=key($HTTP_POST_VARS);
next($HTTP_POST_VARS)) {
$this = addslashes($HTTP_POST_VARS[$key]);
$this = strtr($this, ">", " ");
$this = strtr($this, "<", " ");
$this = strtr($this, "|", " ");
$$key = $this;
}
//
//I have the values for mysql.host.com, username,
//password, and database_name set up properly in the real file
if ($newUser && $newPass ) {
$query = "insert into auth (userid,username,userpassword) ";
$query .= "VALUES(0000,'$newUser','$newPass')";
mysql_connect("mysql.host.com","username","password")
or die("Unable to connect to SQL server");
mysql_select_db("database_name") or die("Unable to select database");
$result = mysql_query($query) or die("Insert Failed!");
}
}
//
if ( $result ){
print "response=You have successfully entered ".$newUser." with the password of ".$newPass." into the database!!";
}
?>
<?
$queryb="SELECT COUNT(*) FROM auth";
mysql_connect("mysql.host.com","username","password")
or die("Unable to connect to SQL server");
mysql_select_db("database_name") or die("Unable to select database");
$numusers=mysql_query($queryb) or die ("Select Failed - count");
$numuser=mysql_fetch_array($numusers);
//
print "userNumber=There are currently " echo $numuser[0]; "users in the database.";
//userNumber is another dynamic text box's variable in flash file
?>
[COLOR=DarkRed][SIZE=4]ANY help would be greatly appreciated!!![/SIZE][/COLOR]
thanks in advance…