Send information to a file on server

Hi, I’m working on a site in flash and have created a message board for it. What it does is display information from an rdf file on my server.

I asked this question over at the flash forums but am trying to be more target specific. I’ve been searching for the information but am so new to PHP that I don’t know where to start!

So here’s my question if I may:

When the user submits a form from the site I’d like it to send information (such as Title, Name, Subject, Link and Message as well as logging the date it was submitted) to a file on my server and add the script to the very bottom. The thing is, it needs to be formatted in a certain way. Here is an example of what I need:

Title Goes Here Link In Here Message Goes Here The Subject Here Name of User Here Log Date Here

The reply I got at the flash forums was:

“flash can send data to a server-side file but it can’t write to a server-side file. so, you’ll need a server-side file (like php) that will write to your rdf file.”

How can I do this? Thanks so much!!

i need some more infos:

i guess u wanna use loadXML(), to load that file back into flash?

how do u wanna set up the securety, so that only the people that are alowed may look at the data?

what are the variables u are submitting, and how du u submit them? get or post?

is there a MySQL database available?
it better to insert the data into a mysql database with and use php to get that format back.

plz give me some more information, so that i will be able to help u.

Hi, yes I’d like to use the loadXML() function; that will automatically keep the message board up to date right?

At the moment all I have is the Message board, and the only way to put new information on it is to edit the rdf file I have. I’m trying to set up the user input area and submit button now.

It’s a simple message board where anyone will be allowed to leave a comment, so I don’t need to put security or restriction in place.

I hadn’t heard of MySQL but I’ve been looking it up. That would be great. I’m really open to suggestions.

I’m sorry I couldn’t provide more information, I’m like a fish out of water with all this.

Danke!

ok first of all find out about MySQL cause editing a file with a scrip-language is a little more complicated.

ur data would fit into one table very easy.

then u have to get the idea of php.
its a script on the server. when u eter its url ist not passed on to the clien, but is executed and its output is send to the client as if it was a html/xml file.

to get interaction done php is able to grap the information providid by the get or post method via the http protcol.

if u start up with a simple file, it gonna get clear soon.

the first thin u have to do is surounding all code with ‘<?php' and '?>’.

u will not gonna get big problems with the syntax as it is C style, like actionscript.

try to pu a file there that only outputs something:

[code]<?php
header(“ContentType: application/xml”);

echo “”;
echo “”;
echo “Title Goes Here”;
echo “Link In Here”;
echo “Message Goes Here”;
echo “dc:subjectThe Subject Here</dc:subject>”;
echo “dc:creatorName of User Here</dc:creator>”;
echo “dc:dateLog Date Here</dc:date>”;
echo “”;
echo “”;
?>[/code]
call it whatever.php put i to the sever and view it in ur browser.

u may have recognices the header() thats there because by default a text/html header is sent.

then u may try to use some variables. the ‘.’ is used to combine strings, instead of the ‘+’. u gonna get used to this soon.

[php]
echo “”;
echo “”;
echo “” . $_GET[‘title’]. “”;
echo “” . $_GET[‘link’]. “”;
echo “” . $_GET[‘description’]. “”;
echo “dc:subject” . $_GET[‘subject’]. “</dc:subject>”;
echo “dc:creator” . $_GET[‘creator’]. “</dc:creator>”;
echo “dc:date” . $_GET[‘date’]. “</dc:date>”;
echo “”;
echo “”;
[/php]

and then call the script this way: whaterver.php?title=Hello+World&link= …

then u should be ready to learn a bit of php. if u do so u’ll find out soon that the combination of flash and php will make u able to do a lot of nice things that can’t be done with just flash.

try to read the introduction and the tutorial at: http://php.net/manual

and please read the capters aubout these functions:
http://php.net/mysql_connect
http://php.net/mysql_query
try as well to understand php-arrays

and try to get used to PHPMyAdmin

for now i guess thats enough homework :)

Great, I’m starting to get a good idea on how this is gonna work.

I found out that my webhosting service doesn’t support PHP. Really lame. I’ll have to get a new service before I can proceed.

u may wanna download and install an apache package including php, mysql, and phpmyadmin e.g. xampp

it installs within a few minutes. and is configured already. then u may develop and test everything locally. so u don’t have to upload it to test it.

Okay, I switched to a hosting plan that will work with PHP and has MySQL already.

I’ve got my form ready in flash, but I’m having some difficulty scripting the correct php for it. How would I get it to collect the information I’m sending?

sry that i didn’t reply earlier, my reply takes some time and the server was down for a while

ok, back to ur prob/teaching

two things:

  1. i don’t wanna write a script for u. i would have had less typing/thinking if i would have just done that. but i thing u are ready to learn php. and i will sleep better, as soon as i know i brout u to the point where u would have been able to do that on ur own. but i will provide a script for u soon.

  2. u still have to do some "homework :)".

ok now we are ready to start. i told u that u would have to get used to PHPMyAdmin. do u have one now? otherwise i’m kind’o wasting my time with the next lines.

create ur table!

u dont need much more than the informatin u provided with ur xml-example. u propaby only have one db. so u just have to create a table with 7 colums:
id: u sould always create one (if u get used to MySQL later it will get 100% clear why, for now just trust me). this is a colum where u have to chose the options: {int, auto increnemt and primary key}
title: {varchar 255 should be enough [thats the max-lenght of a varchar]}
link: {varchar 255 as well}
description: (no idea wat goes in there {varchar 255 or text}, i guess is’t the actual message that meens it’ll need linefeeds and more than 255 chars, if my suggestion is right is’t “text”)
dc_subject: {varchar 255}
dc_creator: {varchar 255}
dc_date: i like to use unixtimestamps u may have head of them, its an int {int} that containd the second since 1.1.1970 0:00 am. this is my way of programming, but iknow a lot that use a {time} field, and i know most of them get into trouble because of using this.

ok that is neary to much of information. just create this table. and get used to PHPMyAdmin: that means insert all data as well, and everytime u do somethinmg take a look at the box with the SQL satement that was used to do wat u just did by clicking an filling-out.

u need to SQL-statements for ur scripr, one to insert and onr to get ur data out of there. if u are inseting all of the allready existing data and play around with the “brouse” and “search” tab of PHPMyAdmin u sould be able to tell me this two qurys u need.

try this and take alook at…
http://php.net/time
http://php.net/date
… and then u will find nothing new, in the script u need.

i hope u reply

Sponsor our Newsletter | Privacy Policy | Terms of Service