|
-
help refining php to txt to flash
Hi all
I've just spent a couple of days looking for tutorials but i've found I'm really quite PHP illiterate so any help here would be awesome.
I have created a flash game that will later be used for a competition so i need to capture the usual user variables such as Name, Email, Score, Var1, Var2.
I have no problem sending the variables out of flash using this script
stop();
var myVars:LoadVars = new LoadVars();
myVars.onLoad = function() {
if (myVars.verify == "success") {
status_txt.text = "data Saved";
} else {
status_txt.text = "Failed Save";
}
};
submit_btn.onRelease = function() {
if (!email_txt.length || email_txt.indexOf("@") == -1 || email_txt.indexOf(".") == -1) {
status_txt.text = "Invalid Email.";
} else if (!name_txt.length) {
status_txt.text = "Missing Name";
} else {
myVars.userName = name_txt.text;
myVars.userEmail = email_txt.text;
myVars.userScore = score_txt.text;
myVars.userCity = City_txt.text;
myVars.sendAndLoad("info.php, myVars, "POST");
}
};
the php script i need help with though here it is.
<?php
$userName = $_POST['userName'];
$userEmail = $_POST['userEmail'];
$userScore = $_POST['userScore'];
$userCity = $_POST['userCity'];
$add = $userName . "<" . $userEmail . ">;";;
$open = fopen('users.txt', 'a');
$write = fwrite($open, $add);
if($write) {
echo "&verify=success&";
} else {
echo "&verify=fail&";
}
?>
obviously first off the only fields that will be writen to txt will be the first two, as I haven't included the score and city variables. This is because i am not sure of the syntax, so some help here would be great.
Secondly the txt file that is writen will show as folows.
john<[email protected]>;bob<[email protected]>;
I imagine with the correct syntax it will read like this
john<[email protected]><5645><Joburg>;bob<bdid@gmail. com><2343><Cape Town>;
I want to create a flash page with all the collected user details but in this format it is difficult for me to to load all the variables and create text boxes that will display the relavent content.
The only solution i could think of was to have the php script to number each profile ie
1User = john&
1Email = [email protected]&
1Score = 5645&
1City = Joburg&
2User = bob&
2Email = [email protected]&
2Score = 2343&
2City = Cape Town&
and so on.
But i have no idea how to modify the php to write consecutive lables like this. I'm not even sure if this makes much sence as a solution.
So any ideas or thoughts are very welcome. I'm almost completely bald in the one section of my head now.
J
Last edited by Beef Cake; 02-06-2008 at 07:42 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|