| |||||||
Du magst keine Werbung? Wir auch nicht!
Einfach registrieren und die Werbung ist weg. Diese Nachricht sehen nur nicht registrierte Nutzer.
![]() |
| | LinkBack | Themen-Optionen | Ansicht |
| | #1 (permalink) |
| Neuer User Registriert seit: Jan 2005
Beiträge: 159
|
hallo, ich möchte für ein gewinnspiel bestimmte daten (ergebnnisse) an ein mailscript übergeben. ich weiß aber nicht wie ich das hinbekomme weil ich nicht verstehe wie ich die gesendeten daten von flash im mailscript verarbeiten muß. das gewinnspiel hat phps die die daten für eine highscore in eine datei speichern und wieder an flash, zum auslesen, übergeben. nun möchte ich aber zusätzlich gerne das die ergebnisse per email gesendet werden. zum speichern der highscore wird folgendes button-AS verwendet: Code: function onBtnApply() {
if(_root.modeHighscore == 0) {
_root.addScoreItem(txtPlayersName);
_root.saveHighscore();
}
if(_root.modeHighscore == 1) {
var d = new Date();
var strDate = d.getDate() + "." + (d.getMonth() + 1) + "." + d.getFullYear() + " " + d.getHours() + ":" + d.getMinutes();
loadVariablesNum("save_score.php?p=" + _root.gamePoints + "&n=" + escape(txtPlayersName) + "&d=" + escape(strDate) + "&l=" + _root.gameLevel + "&t=" + _root.secondsCounter / 1000 + "&a=" + _root.attemptsCounter, "", "POST");
}
btnApply.setEnabled(false);
gotoAndPlay(1);
};
function OnBtnBack() {
gotoAndPlay(1);
}; save_score.php Code: <?php
// Append the score to file
$fp = fopen("memory_highscore.dat", "a");
foreach($HTTP_GET_VARS as $var) {
fputs($fp, "$var" . chr(9));
}
fputs($fp, chr(10));
fclose($fp);
?> Code: <?php
// Add spaces to string
function formatString($var, $length) {
$ret = $var;
if(strlen($ret) > $length) {
$ret = substr($ret, 0, $length);
}
$n = strlen($ret);
for($i = 0; $i < strlen($ret); $i++) {
if(ord(substr($ret, $i, 1)) > 192) {
$n--; // UNICODE, count only 1x
$i++;
}
}
$n = $length - $n;
if($n > 0) {
$ret = $var.str_repeat("%20", $n);
}
return $ret;
}
// Sort function used by usort
function sortfunc($val1, $val2) {
return ($val1["p"] < $val2["p"]);
}
// Count of highscore entries
$count = 10;
if(isset($HTTP_GET_VARS['count'])) {
$count = $HTTP_GET_VARS['count'];
}
// Header
$s1 = formatString("Punkte", 7);
$s2 = formatString("Name", 22);
$s3 = formatString("Zeit", 5);
$s4 = formatString("Versuche", 10);
$s6 = formatString("Datum", 16);
$score = $s1.$s2.$s3.$s4.$s5.$s6.chr(10);
// Read entries from file into an array
$i = 0;
$fp = fopen("memory_highscore.dat", "r");
while($strLine = fgets($fp, 100)) {
$arr = split(chr(9), $strLine);
$arrarr{$i} = array("p" => $arr[0], "n" => $arr[1], "d" => $arr[2], "l" => $arr[3], "t" => $arr[4], "a" => $arr[5]);
$i++;
}
fclose($fp);
// Sort the array
usort($arrarr, sortfunc);
// Print the array
$i = 1;
while(list($id, $val) = each($arrarr)) {
if($i > $count) {
break;
}
$s1 = formatString($arrarr{$id}{"p"}, 7);
$s2 = formatString($arrarr{$id}{"n"}, 22);
$s3 = formatString($arrarr{$id}{"t"}, 5);
$s4 = formatString($arrarr{$id}{"a"}, 10);
$s6 = formatString($arrarr{$id}{"d"}, 16);
$score = $score.$s1.$s2.$s3.$s4.$s6.chr(10);
$i++;
}
echo "&txtScore="."$score"; // Flash variable, attached to the highscore textfield
?> mail.php Code: <? $empfaenger = "mirco_gutschmidt@online.de"; $betreff = "Nachricht Memorygewinnspiel"; $from = "From: ".utf8_decode($_POST['txtPlayersmail'])."\n"; $txt = "Name: ".utf8_decode($_POST['txtPlayersName'])."\n\n\n"; $txt .= "Erziehlte Punktzahl: ".utf8_decode($_POST['gamePoints'])."\n"; $txt .= "Versuche: ".utf8_decode($_POST['gameLevel'])."\n"; $txt .= "Benötigte Zeit: ".utf8_decode($_POST['strDate'])."\n"; mail($empfaenger, $betreff, $txt, $from); ?> Danke Geändert von Mirco_XP (09-05-2008 um 11:15 Uhr) |
| | |
![]() |
| Lesezeichen |
| Themen-Optionen | |
| Ansicht | |
| |