Ok, I’m trying to make a shout box using PHP and Flash, it’s not working though… You can see what I have so far at www.barbdwyer.com/T6 . I don’t know PHP, so I had one of my friends write the script for me, but he doesn’t know Flash, so he couldn’t help me set it up.
in flash, i have the following code on my submit button:
on(press) {
getURL ("add.php", "_blank", "POST");
}
i also have this in a frame:
onEnterFrame = function () {
Name = theName.text;
Email = theContact.text;
Comments = theMessage.text;
};
then here’s the PHP scripts.
one called add.php:
<?php
$Name = ereg_replace("[^A-Za-z0-9\<\>]", "", $Name);
$Email = ereg_replace("[^A-Za-z0-9 \@\.\-\/\'\<\>]", "", $Email);
$Comments = ereg_replace("[^A-Za-z0-9 \@\.\-\/\'\<\>]", "", $Comments);
$Name = stripslashes($Name);
$Email = stripslashes($Email);
$Comments = stripslashes($Comments);
if ($Submit == "Yes") {
$filename = "shoutbox.txt";
$fp = fopen( $filename,"r");
$OldData = fread($fp, 80000);
fclose( $fp );
$Input = "<a href=\"mailto:$Email\"><b>$Name</b></a>: $Comments<br><br>.:::.";
$New = "$Input$OldData";
$fp = fopen( $filename,"w");
fwrite($fp, $New, 80000);
fclose( $fp );
Header("Location: shoutbox.php");
}
?>
one called forum.php:
<?php
$Name = ereg_replace("[^A-Za-z0-9\<\>]", "", $Name);
$Email = ereg_replace("[^A-Za-z0-9 \@\.\-\/\'\<\>]", "", $Email);
$Comments = ereg_replace("[^A-Za-z0-9 \@\.\-\/\'\<\>]", "", $Comments);
$Name = stripslashes($Name);
$Email = stripslashes($Email);
$Comments = stripslashes($Comments);
if ($Submit == "Yes") {
$filename = "shoutbox.txt";
$fp = fopen( $filename,"r");
$OldData = fread($fp, 80000);
fclose( $fp );
$Input = "<a href=\"mailto:$Email\"><b>$Name</b></a>: $Comments<br><br>.:::.";
$New = "$Input$OldData";
$fp = fopen( $filename,"w");
fwrite($fp, $New, 80000);
fclose( $fp );
Header("Location: index.php");
}
?>
<form name="shoutbox" action="form.php" method="post">
<table align="center" border="0">
<tr>
<td>Name:</td>
<td><input type="text" name="Name"></td>
</tr>
<tr>
<td>Email:</td>
<td><input type="text" name="Email"></td>
</tr>
<tr>
<td>Message:</td>
<td colspan="2" align="right">
<textarea name="Comments"></textarea>
<input type="hidden" name="Submit" value="Yes">
</td>
</tr>
<tr>
<td colspan="2" align="right"><input type="submit" value="Submit"></td>
</tr>
</table>
</form>
and finally, one called shoutbox.php:
<?php
$filename = "shoutbox.txt";
$fp = fopen($filename,"r");
$Data = fread($fp, 80000);
fclose( $fp );
$DataArray = split (".:::.", $Data);
//Put in the starting tag and the ending tag number
for ($n = 0; $n < 20; $n++) {
print $DataArray[$n];
}
?>
then there is an empty text file called shoutbox.txt
I am completely confused, he told me to make the add.php from the php part of the forum.php, and I know that this worked when it was in HTML, but I got a headache trying to get it to work in flash. Can someone please help, thanks