Jump to content

PHP write to file


urtwithac

Recommended Posts

Hey, i'm having a bit of trouble with a form i created in flash, having the PHP process the variables and send them to a text file, that i can then read.

I have got somewhere atleast...

Name: Undefined Address: Undefined

are what i get in my text file on my server, not what is actually typed in the form fields.

If anyone could tell me why it's doing this, it'd be appriciated.

Here's my code:
PHP:
[code]<?php
$content = "Name:".$_POST["name"]." Address:".$_POST["address"];
$fp = fopen("myText.txt","wb");
fwrite($fp,$content);
fclose($fp);
?>[/code]
Link to comment
Share on other sites

Here's the code that's on my submit button,

my fields each have their own variable names:
name
address

[code]
on (release) {
writeLVs = new LoadVars();
writeLVs.name = Name.text;
writeLVs.address = Address.text;
writeLVs.send("writeData.php?uniqueID="+getTimer(),writeLVs,"$_POST");
}
[/code]
Link to comment
Share on other sites

$content = "Name:".$_POST["name"]." Address:".$_POST["address"];
Name and Address must be capitalized, as that's how you did it in your flash. PHP is case-sensitive.
Change to:
$content = "Name:".$_POST["Name"]." Address:".$_POST["Address"];
Link to comment
Share on other sites

I know nothing about flash, but I've made some googling .
Are you sure it's supposed to be: [code]writeLVs.send("writeData.php?uniqueID="+getTimer(),writeLVs,"$_POST");[/code]
And not
[code]writeLVs.send("writeData.php?uniqueID="+getTimer(),writeLVs,"POST");[/code]

Orio.
Link to comment
Share on other sites

i have used flash and know a tad about sending data from flash to php. from my experience it should be just POST not $_POST. they must have an instance name that flash will read and a var name that PHP can read.
and  what your doing there, using the LoadVars will load information from a  PHP file. your actionscript should look like this:

[code]
on(release){

var name = name; //these need to be defined for php
var address = address; //these need to be defined for php

getURL("writeData.php?uniqueID="+getTimer(), "_parent", "POST"); //the sending of the info. _parent is what window it opens in
}
[/code]

hope that works for you.
Link to comment
Share on other sites

I can't figure out why it isn't working, they're input fields, have both var and instance names.

Although i'm getting "Name: Address:" in my text file, could it be permissions with CHMOD?

i don't know. i'm out of ideas.

Maybe i have the wrong instance and var names.

Thanks again,


Curt.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.