PDA

View Full Version : Variables not writing to text file


TurtleCreek
01-15-2005, 11:39 PM
I need help!!! I am new to PHP and I am trying to fashion together a contact form that will pass the variables from Flask into a text file. For some reason, though, the PHP file runs and creates the text file but none of my variables are getting written into the file. Below is the code I have in my PHP file:

<?php

$f=fopen("turtlecreek.txt","a");

fwrite($f,"*****************************\r\n");
fwrite($f,"First Name:\t"$_POST['fname']"\r\n");
fwrite($f,"Last Name:\t"$_POST('lname')"\r\n");
fwrite($f,"Address:\t"$_POST['addr']"\r\n");
fwrite($f,"City:\t"$_POST['city']"\r\n");
fwrite($f,"State:\t"$_POST['state']"\r\n");
fwrite($f,"Zip Code:\t"$_POST['zip']"\r\n");
fwrite($f,$_POST['dayph']);
fwrite($f,$_POST['evenph']);
fwrite($f,"Email Address:\t"$_POST['email']);
fwrite($f,"Contact Method Preferred:\t"$_POST['cntmeth']);
fwrite($f,$_POST['mess']);

fclose($f);

?>

As for my Flash end, I have a submit button which, when clicked, executes the LoadVariables action.

on (release, releaseOutside) {
loadVariablesNum("Process_Form.php", 0, "POST");
}

I have the form as a movie clip and the frame is stopped until the OnClipEvent(data) executes, at which time the frame advances forward two frames. What am I doing wrong?

CyanBlue
01-16-2005, 02:32 PM
Howdy and Welcome... :)

I've moved the thread to the Server Side Scripting forum since your problem mainly resides within your PHP code...

Okay... The basic rule is that you will need to provide the output in the form of 'variable1=valu1&variable2=value2'... I think your script should work as soon as you change the format...
echo("FirstName=" . $_POST['fname'] . "&");
Also, try to use LoadVars() object instead of loadVariables() function...

TurtleCreek
01-16-2005, 10:12 PM
I have switched out the loadVariables function for the LoadVars object with no problem. But, after making the change in my PHP code I still am not seeing a text file appear with my variables in them. Previously, I would get a text file written on my server but it only contained what I had hard-coded in parentheses within the fwrite function. Now, I don't even see a text file at all. help? please :confused:

I am trying to put text into a text file from Flash not pull it in from Flash. At least, not yet anyway. ;)

CyanBlue
01-16-2005, 10:13 PM
Can you post your fixed PHP script???

TurtleCreek
01-16-2005, 10:30 PM
Here it is:

<?php

$f=fopen("turtlecreek.txt","a");

fwrite($f,"*****************************\r\n");
fwrite($f,"First Name:\t".$_POST['fname']"\r\n");
fwrite($f,"Last Name:\t".$_POST('lname')"\r\n");
fwrite($f,"Address:\t".$_POST['addr']"\r\n");
fwrite($f,"City:\t".$_POST['city']"\r\n");
fwrite($f,"State:\t".$_POST['state']"\r\n");
fwrite($f,"Zip Code:\t".$_POST['zip']"\r\n");
fwrite($f,"Daytime Phone Number:\t".$_POST['dayph']"\r\n");
fwrite($f,"Nighttime Phone Number:\t".$_POST['evenph']"\r\n");
fwrite($f,"Email Address:\t".$_POST['email']);
fwrite($f,"Contact Method Preferred:\t".$_POST['cntmeth']);
fwrite($f,"Comments:\t".$_POST['mess']"\r\n");

fclose($f);

echo("FirstName=".$_POST['fname']);

?>

Could I be squashing the call somehow?

TurtleCreek
01-16-2005, 10:33 PM
I only put the first variable in the echo as a test....btw.

TurtleCreek
01-17-2005, 03:04 AM
After consulting with my wife on what she preferred, she liked it better if the info was emailed to us instead. So, I noticed your thread regarding another chap's problems with PHP and Flash and I thought what you suggested would work great -- and it did. Thanks a bunch lad!! :p

CyanBlue
01-17-2005, 03:49 PM
Howdy... :)

Sorry... I was not able to take a look at the AS.org threads over the weekend...

Glad to hear that you were able to figure it out... and it'd be great if you could post the solution so that somebody else who has the same problem can get help out of what you have found out... :)