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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.