Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 05-16-2005, 11:24 AM   #1
padone
Registered User
 
Join Date: Dec 2004
Posts: 168
Unhappy help with save to php

Hi

I have 3 simple input txt fields in my movie one for your name, email, and just a message.

Now in flash I have all on the same keyframe the 3 text fields called name, email and besttime and a button with this code on it..
ActionScript Code:
on(release){ loadVariablesNum ("try.php", 0 ,"POST");}

then I have a php file called try.php with this in it
PHP Code:
<?php
$data
="test.txt";
$fpfopen($data"w+");
$fwfwrite($fp,"$QUERY_STRING");
fclose($fp);
echo 
"status=Done"
?>
I was told that this should work fine but the thing is it doesnt seem to right anything to my txt file do i need anything else in the flash,php or even in the txt file???

Last edited by CyanBlue; 05-16-2005 at 02:30 PM. Reason: PHP tag is applied
padone is offline   Reply With Quote
Old 05-16-2005, 02:27 PM   #2
padone
Registered User
 
Join Date: Dec 2004
Posts: 168
Default saving more than once

Hey I have now got my flash to save to a txt file but I need it to save more than once this is my actionscript on the first frame
ActionScript Code:
submit.onPress = function(){     if(Title.text!="" && Comments.text !="" && Image.text!=""){         myData.Title = Title.text         myData.Comments = Comments.text         myData.Image = Image.text         myData.sendAndLoad("save.php", myData, "POST") //php         //myData.sendAndLoad("save.asp", myData, "POST") //asp         //myData.sendAndLoad("save.cfm", myData, "POST") //cf     } } myData = new LoadVars() myData.onLoad = function(){    if(this.writing=="Ok") {        gotoAndStop(2)              status.text = "Submited data was saved"    }    else status.text = "Error in saving submitted data" } stop()
and on my second frame is
ActionScript Code:
stop()
also in my php i have
PHP Code:
<?php
   
//Capture data from $_POST array
   
$title $_POST['Title'];
   
$comments $_POST['Comments'];
   
$image $_POST['Image'];
   
//Make one big string in a format Flash understand
   
$toSave "Title=".$title."&Comments=".$comments."&Image=".$image;
   
//Open a file in write mode
   
$fp fopen("anastasio.txt""w");
   if(
fwrite($fp$toSave)) echo "writing=Ok";
   else echo 
"writing=Error";
   
fclose($fp);   
?>

Last edited by CyanBlue; 05-16-2005 at 02:31 PM. Reason: PHP tag is applied
padone is offline   Reply With Quote
Old 05-16-2005, 02:31 PM   #3
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Howdy and Welcome...

I have a question for you... WHAT are you trying to save???
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 05-16-2005, 02:35 PM   #4
padone
Registered User
 
Join Date: Dec 2004
Posts: 168
Default

basically i have a game that records the amount of time taken to race around a track and at the end of the game i have made it so that you can put in your email address and send your result to a friend.

I would like to save the email address in a txt file when they click send???

This is to build a mailing directory just for me
padone is offline   Reply With Quote
Old 05-16-2005, 02:37 PM   #5
padone
Registered User
 
Join Date: Dec 2004
Posts: 168
Default I now have it saving

I have the php saving to a txt file now but need it to add onto the .txt file instead of overwriting it???
padone is offline   Reply With Quote
Old 05-16-2005, 02:57 PM   #6
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Well... Play with the sample that I am posting... and I am going to merge the other thread cuz we don't want the threads flying all over the forum...
Attached Files
File Type: zip saveStat.zip (5.1 KB, 783 views)
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 05-21-2005, 11:29 PM   #7
dankdoutz
Doom for Dank and Scud!
 
dankdoutz's Avatar
 
Join Date: Apr 2005
Location: Hawaii
Posts: 20
Default Just change the extension for the fopen tag.

Quote:
Originally Posted by padone
I have the php saving to a txt file now but need it to add onto the .txt file instead of overwriting it???
Just change the extension for the fopen tag.

eg:
PHP Code:
<?php
// Build log data
$log =    "$dateStamp|";
$log .=    "$logData";

$fileName "xx_log.txt";

if (
$fileHandle fopen ($fileName"a"))
{
// File was created, so insert data into file.
fputs ($fileHandle$log);
}
else
{
}
?>
From php.net:


'r' Open for reading only; place the file pointer at the beginning of the file.
'r+' Open for reading and writing; place the file pointer at the beginning of the file.
'w' Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.
'w+' Open for reading and writing; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.
'a' Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
'a+' Open for reading and writing; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
'x' Create and open for writing only; place the file pointer at the beginning of the file. If the file already exists, the fopen() call will fail by returning FALSE and generating an error of level E_WARNING. If the file does not exist, attempt to create it. This is equivalent to specifying O_EXCL|O_CREAT flags for the underlying open(2) system call. This option is supported in PHP 4.3.2 and later, and only works for local files.
'x+' Create and open for reading and writing; place the file pointer at the beginning of the file. If the file already exists, the fopen() call will fail by returning FALSE and generating an error of level E_WARNING. If the file does not exist, attempt to create it. This is equivalent to specifying O_EXCL|O_CREAT flags for the underlying open(2) system call. This option is supported in PHP 4.3.2 and later, and only works for local files.

Last edited by CyanBlue; 05-22-2005 at 02:16 PM. Reason: PHP tag is applied...
dankdoutz is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Q] How to Save Text File in Flash??? CyanBlue Other Flash General Questions 7 03-12-2012 09:16 AM
Problem with AS and PHP, have to click button twice to return variable from php jetgrind ActionScript 2.0 5 10-19-2005 07:43 AM
txtArea, PHP, XML, and CSS: Nothing I do formats the text PhishIn4Dmb Components 0 09-22-2004 03:16 PM
major problem with flash & php niobi xd Server-Side Scripting 3 09-20-2003 04:48 AM
Sending Flash variables to PHP alphabug Other Flash General Questions 1 08-02-2003 02:10 AM


All times are GMT. The time now is 09:09 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.