AS3 to PHP to MySQL issue

  • stunningstylez
  • Born
  • Born
  • stunningstylez
  • Posts: 4

Post 3+ Months Ago

I have searched for a solution over many forums and none of the code seems to work. I cannot get AS3 to work with a php script.
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";

?>
  • Satwant
  • Graduate
  • Graduate
  • User avatar
  • Posts: 127
  • Loc: Bangalore

Post 3+ Months Ago

stunningstylez wrote:
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);

Is this Change add something to your Luck :)

Code: [ Select ]
var variables:URLVariables = new URLVariables;
variables.userName = user_txt.text;
variables.userPass = pass_txt.text;
variables.userEmail = email_txt.text;
var varSend:URLRequest = new URLRequest("register.php");
varSend.method = URLRequestMethod.POST;
varSend.data = variables;
var varLoader:URLLoader = new URLLoader;
varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
varLoader.load(varSend);
  1. var variables:URLVariables = new URLVariables;
  2. variables.userName = user_txt.text;
  3. variables.userPass = pass_txt.text;
  4. variables.userEmail = email_txt.text;
  5. var varSend:URLRequest = new URLRequest("register.php");
  6. varSend.method = URLRequestMethod.POST;
  7. varSend.data = variables;
  8. var varLoader:URLLoader = new URLLoader;
  9. varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
  10. varLoader.load(varSend);
  • stunningstylez
  • Born
  • Born
  • stunningstylez
  • Posts: 4

Post 3+ Months Ago

Nope it is still not registering :-( I am not sure if it's something wrong with the action script or
any other issue, but seems everything is in working order and running the php file by itself registers. Appreciate the quick response friend
  • Satwant
  • Graduate
  • Graduate
  • User avatar
  • Posts: 127
  • Loc: Bangalore

Post 3+ Months Ago

The First need to look for Real Problem.
Your action Script is not able to connect to php file
Check this with following code. Add the code to your php file.
Code: [ Select ]
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fclose($ourFileHandle);
  1. $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
  2. fclose($ourFileHandle);

If file is created on server then the action script is attaching to your php file.
If not then The problem may be in your file location. Try to Use full absolute URL.
  • stunningstylez
  • Born
  • Born
  • stunningstylez
  • Posts: 4

Post 3+ Months Ago

ahhhh Satwant thanks so much, thats exactly what I needed to do...just put the full url. Man I wish I would have just put that in...life saver thanks again!
  • Satwant
  • Graduate
  • Graduate
  • User avatar
  • Posts: 127
  • Loc: Bangalore

Post 3+ Months Ago

U welcome :)

Post Information

  • Total Posts in this topic: 6 posts
  • Users browsing this forum: No registered users and 130 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.