|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Flash +php News?
I'm pretty effecient when it comes to flash and AS, but I really don't know anything about php or perl, or mySQL, and such. What I'd really like to be able to do is have users login to a secure section of a flash site, and then be able to append (or even better, add to the top) of a txt or xml file, so I could read that into flash and display its data (I know how to do that part) What I have no clue whatsoever about is sending the info and retrieving the data, using php, or perl, or any of those scripting languages.
Does anyone have an example they could show me? Or even better, explain to me how to build one, I'd really appreciate the help. Thanks everyone. (my server has php, perl, mysql, all that good stuff ) |
|
#2
|
|||
|
|||
|
Im gonna assume you are using flash MX.... to send and load variables out of flash to a php script or perl script, you need to do the following....
Code:
var1 = "text to send";
var2 = "more text to send";
URL = "http://yourdomain.com/yourphpscript.php";
varObject = new LoadVars();
varObject.username = var1;
varObject.password = var2;
varObject.sendAndLoad(URL,this,"POST");
varObject.onLoad = function(){
//do stuff with loaded variables here.... ill explain how to get them here in just a second.
}
Make a php or perl script to parse the info and check it against a text file or an sql database (depending on how many people you expect to visit) and send the info back to the browser... in php its done like this...... PHP Code:
in perl PHP Code:
Those should be the responses to your browser after the flash movie makes a query to that file. in both cases '$username' is equal to the username passed to the file and '$passCorrect' is a boolean to wether or not the user supplied a valid password. Once this data is back into flash access it like so... Code:
// continue from where we left off.....
varObject.onLoad = function(){
if (varObject.passCorrect){
gotoAndPlay("loggedIn");
}
}
Let me know if you have any further questions.. id love to help you out if ya need anything. JCMerlin@sbcglobal.net |
|
#3
|
|||
|
|||
|
Thanks for the info JC, but the main part of my question was after logging in, I want a person to be able to enter text into an input text field, and then have that text sent as a string to a php or perl script that would then append (or even better, place at the top) that data to an xml or txt file. The problem is, I don't know how to write php or perl, so if anyone could help me with that part or direct me to a working open source code so I could view and learn from that, I'd really appreciate it. Thanks again
|
|
#4
|
|||
|
|||
|
sorry, lost track :\ ...
create a file for the text and name it whatever... for the sake of it ill call it news.txt and it will be placed in the same directory as the perl file. Also, the name of the text field that your users will type in i called 'textField'. Code:
#!/usr/bin/perl -wT
use strict;
use CGI;
use Fcntl qw(:DEFAULT :flock);
my ($str,@lines);
$str = param('textField');
open(F,"+<news.txt") || die "Couldnt open news.txt. $!";
flock(F,LOCK_EX);
@lines = <F>;
print F ($str . @lines);
truncate(F, tell(F));
close <F>;
Try that...... :\ btw, dont let the stupid smily thing up there confuse ya... its a : followed by a D ![]() |
|
#5
|
|||
|
|||
|
Ah that looks great, I'll give it a shot and let ya know, thanks!
|
|
#6
|
|||
|
|||
|
crap, one change......
Code:
print F ($str . "/n" . @lines); |
|
#7
|
|||
|
|||
|
php alternative?
Is there a php alternative to this perl script?
I've been trying to find a way of outputting a flash readable text file using php, and a pared down html front end, a simple cms thing. I basically want to be able to go to an htaccess directory with a simple html form in, with input boxes for title and news content, and when the form is submitted it boots out the correctly formatted text file news.txt which i can then move to the directory running my flash movie. The only other way I can think of this is thru a complex mod of one of those flash guestbook tutorials, but that seems a bit extreme for what I'm after. thanks in advance d. |
![]() |
| Viewing: Dev Shed Forums > Web Design > Flash Help > Flash +php News? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|