ok, er på igen..kunne ikke få dit script til at virke i første omgang..har lagt alt i samme mappe, har slået firewall fra, etc..det er som om flashen ikke kan læse php uden at jeg har noget at ha det i som sådan.
777 er eller rettere, var slået til da jeg loadede op på azero. Indtil det virker på apachen så lader jeg azero være.
Gæstebogen jeg har bygget i flash har variablen guestbook.php i send knappen der ligger i et movieclip der indeholder formularen.
actionscript til sendknap:
on (release) {
if (Name eq "") {
_root.Status = "Please enter your name";
} else if (Email eq "") {
_root.Status = "Please enter an email address";
} else if ( Email("@") > +1) {
_root.Status = "Please enter an email address";
} else if (Comment eq "") {
_root.Status = "Please write a comment";
} else {
Submit = "Yes";
NumHigh = 10;
NumLow = 0;
_root.GuestBook = "Processing.. Loading New... ";
loadVariablesNum ("GuestBook.php", 0, "POST");
_root.Status = "Your entry has been submitted. You should see your comments appear immediatly";
gotoAndStop (2);
}
}
I første frame første scene:
NumLow = 0;
NumHigh = 10;
loadVariablesNum ("GuestBook.php?NumLow="+NumLow+"&NumHigh="+NumHigh+"&R="+random(999), 0);
stop();
Previousknap:
on (release) {
if (NumLow == "0") {
GuestBook = "No more before 0";
}
else {
NumLow = Number(NumLow) - Number(10);
NumHigh = Number(NumHigh) - Number(10);
GuestBook = "Loading Comments Numbered "+NumLow+" to "+NumHigh+" Please Hold";
loadVariablesNum ("GuestBook.php?NumLow="+NumLow+"&NumHigh="+NumHigh+"&R="+random(999), 0);
}
}
Nextknap har stort set det samme actionscript bare omvendt.
phpscript med kommentarer og hele smøren:
<?php
// If you are using an old version of php, remove the next set of lines.
// or use $HTTP_POST_VARS["..."] instead.
$Submit = $_POST["Submit"];
$Name = $_POST["Name"];
$Email = $_POST["Email"];
$Website = $_POST["Website"];
$Comments = $_POST["Comments"];
$NumLow = $_REQUEST["NumLow"];
$NumHigh = $_REQUEST["NumHigh"];
// Replace special characters - you can remove the next 5 lines if wanted.
$Name = ereg_replace("[^A-Za-z0-9 ]", "", $Name);
$Email = ereg_replace("[^A-Za-z0-9 \@\.\-\/\']", "", $Email);
$Comments = ereg_replace("[^A-Za-z0-9 \@\.\-\/\']", "", $Comments);
$Website = eregi_replace("
http://", "", $Website);
$Website = ereg_replace("[^A-Za-z0-9 \@\.\-\/\'\~\:]", "", $Website);
// Remove slashes.
$Name = stripslashes($Name);
$Email = stripslashes($Email);
$Website = stripslashes($Website);
$Comments = stripslashes($Comments);
// ###################################################################################
// ########## Reading and Writing the new data to the GuestBook Database #############
if ($Submit == "Yes") {
// Next line tells the script which Text file to open.
$filename = "GuestBook.txt";
// Opens up the file declared above for reading
$fp = fopen( $filename,"r");
$OldData = fread($fp, 80000);
fclose( $fp );
// Gets the current Date of when the entry was submitted
$Today = (date ("l dS of F Y ( h:i:s A )",time()));
// Puts the recently added data into html format that can be read into the Flash Movie.
// You can change this up and add additional html formating to this area. For a complete listing of all html tags
// you can use in flash - visit:
www.macromedia.com/support/flash/ts/documents/htmltext.htm $Input = "Name: <b>$Name</b>
Email: <b><u><a href=\"mailto:$Email\">$Email</a></u></b>
Website: <b><u><a href=\"
http://$Website\" target=\"_blank\">$Website</a></u></b>
Comments: <b>$Comments</b>
<i><font size=\"-1\">Date: $Today</font>
.:::.";
/* This Line adds the '&GuestBook=' part to the front of the data that is stored in the text file. This is important because without this the Flash movie would not be able to assign the variable 'GuestBook' to the value that is located in this text file */
$New = "$Input$OldData";
// Opens and writes the file.
$fp = fopen( $filename,"w");
if(!$fp) die("&GuestBook=cannot write $filename ......&");
fwrite($fp, $New, 800000);
fclose( $fp );
}
// ###################################################################################
// ######### Formatting and Printing the Data from the Guestbook to the Flash Movie ##
// Next line tells the script which Text file to open.
$filename = "GuestBook.txt";
// Opens up the file declared above for reading
$fp = fopen( $filename,"r");
$Data = fread($fp, 800000);
fclose( $fp );
// Splits the Old data into an array anytime it finds the pattern .:::.
$DataArray = split (".:::.", $Data);
// Counts the Number of entries in the GuestBook
$NumEntries = count($DataArray) - 1;
print "&TotalEntries=$NumEntries&NumLow=$NumLow&NumHigh=$NumHigh&GuestBook=";
for ($n = $NumLow; $n < $NumHigh; $n++) {
print $DataArray[$n];
if (!$DataArray[$n]) {
Print "
<b>No More entries</b>";
exit;
}
}
?>
Nogen kommentarer til ovenstående, eller ligefrem svar HVORFOR...?
/milou