I am trying to create a registration form in AS3
and then have that information go to mysql database when
the submit button is pressed.
Here is part of the AS3 code:
var variables:URLVariables = new URLVariables;
var varSend:URLRequest = new URLRequest("register.php");
varSend.method = URLRequestMethod.POST;
varSend.data = variables;
var varLoader:URLLoader = new URLLoader;
varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
variables.userName = user_txt.text;
variables.userPass = pass_txt.text;
variables.userEmail = email_txt.text;
varLoader.load(varSend);
Here is the php script "register.php":
<?php
$db_host = "localhost";
$db_username = "root";
$db_pass = "";
$db_name = "userregister";
mysql_connect("$db_host","$db_username","$db_pass" ) or die ("could not connect to mysql");
mysql_select_db("$db_name") or die ("no database");
$senderName = $_POST['userName'];
$senderPass = $_POST['userPass'];
$senderEmail = $_POST['userEmail'];
$sqlCommand = "INSERT INTO user (username, password, email)
VALUES('$senderName','$senderPass','$senderEmail') ";
$query = mysql_query($sqlCommand) or die (mysql_error());
$my_msg = "Thanks $senderName, all data has been sent.";
echo "return_msg=$my_msg";
?>

New Topic/Question
Reply



MultiQuote




|