Jump to content

php / Flash Register


northernmics

Recommended Posts

Below is a simple register script to register a user through flash and php. It does not matter if the there is an error or not, the &myStatus variable always shows the first statement (username already in use) and if I remove that, the other &myStatus's are not picked up by flash :S

 

I have tried everything and if I create a user it should skip the "if" and go to the "else", which it does, and successfully creates it in the database, but it still picks up the mtStatus located in the "if" statement.

 

 

<?php

include('connect.php');

 

$username = $_POST['username'];

$password = $_POST['pass'];

$password2 = $_POST['pass2'];

$bio = $_POST['bio'];

 

$db = @mysql_connect($host,$dbuser,$dbpass) or die("error=could not connect to $host");

$db = mysql_select_db($dbname, $db);

 

if ($password == $password2){

 

$user = mysql_query("SELECT * FROM users WHERE (username='$username')");

if (mysql_num_rows($user) != 0) {

//this is the only one that will show//

$statusWindow = "&myStatus=Username already in use";

}

else {

 

$user = mysql_query("INSERT INTO users VALUES (NULL, '$username', '$password', '', '')");

$statusWindow = "&myStatus=Username was accepted";

}

}

else{

$statusWindow = "&myStatus=Password already in use";

}

print $statusWindow;

?>

 

Flash frame one

 

btn_Submit.onRelease = function(){

myVars = new LoadVars();

myVars.username = txt_User.text

myVars.pass = txt_Pass.text

myVars.pass2 = txt_Pass2.text

myVars.sendAndLoad('register.php', myVars, 'POST');

txt_User.text = "";

txt_Pass.text = "";

txt_Pass2.text = "";

gotoAndPlay(2);

 

}

 

Flash frame 2

 

statusVars = new LoadVars();

statusVars.load("register.php");

statusVars.onLoad = function() {

_root.myStatus = statusVars.myStatus;

}

 

the text box should change as the myStatus in the php changes.

Link to comment
https://forums.phpfreaks.com/topic/46042-php-flash-register/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.