Seite 1 von 1

umfrage ergebniss in die index.php

Verfasst: 05.02.2009 18:54
von michib1979
hallo zusammen ich habe eine umfrage auf meiner hp komm bloss mit dem code nicht klar das das ergebniss auf der index.php angezeigt wird vielleicht hat jemand von euch eine Idee
hier der code

Code: Alles auswählen

<?php
if(!empty($_GET)) { extract($_GET); }
else if(!empty($HTTP_GET_VARS)) { extract($HTTP_GET_VARS); }

if(!empty($_POST)) { extract($_POST); }
else if(!empty($HTTP_POST_VARS)) { extract($HTTP_POST_VARS); }

if(!empty($_COOKIE)) { extract($_COOKIE); }
else if(!empty($HTTP_COOKIE_VARS)) { extract($HTTP_COOKIE_VARS); }

if(!empty($_ENV)) { extract($_ENV); }
else if(!empty($HTTP_ENV_VARS)) { extract($HTTP_ENV_VARS); }

if(!empty($_SERVER)) { extract($_SERVER); }
else if(!empty($HTTP_SERVER_VARS)) { extract($HTTP_SERVER_VARS); }

if(!empty($_SESSION)) { extract($_SESSION); }
else if(!empty($HTTP_SESSION_VARS)) { extract($HTTP_SESSION_VARS); }

if(!empty($_FILES)) {
while(list($name, $value) = each($_FILES)) {
$$name = $value['tmp_name'];
}
} else if(!empty($HTTP_POST_FILES)) {
while(list($name, $value) = each($HTTP_POST_FILES)) {
$$name = $value['tmp_name'];
}
}
$gelesen=fread(fopen("./umfrage/umfrage/save.txt","r"),filesize("./umfrage/umfrage/save.txt"));
$splitt=explode("¦",$gelesen);

print "<b>".$splitt[0]."</b>
<br />
<br />";

if($splitt[1]!=''){
print "&raquo; <a onclick=\"javascript:window.open('./umfrage/umfrage/ergebnisse.php?save=a1','Umfragen','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=600')\" return false; href=\"#\">
".$splitt[1]."</a><br />";
}

if($splitt[3]!=''){
print "&raquo; <a onclick=\"javascript:window.open('./umfrage/umfrage/ergebnisse.php?save=a2','Umfragen','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=600')\" return false; href=\"#\">
".$splitt[3]."</a><br />";
}


if($splitt[5]!=''){
print "&raquo; <a onclick=\"javascript:window.open('./umfrage/umfrage/ergebnisse.php?save=a3','Umfragen','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=600')\" return false; href=\"#\">
".$splitt[5]."</a><br />";
}

if($splitt[7]!=''){
print "&raquo; <a onclick=\"javascript:window.open('./umfrage/umfrage/ergebnisse.php?save=a4','Umfragen','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=600')\" return false; href=\"#\">
".$splitt[7]."</a><br />";
}

if($splitt[9]!=''){
print "&raquo; <a onclick=\"javascript:window.open('./umfrage/umfrage/ergebnisse.php?save=a5','Umfragen','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=600')\" return false; href=\"#\">
".$splitt[9]."</a><br />";
}

if($splitt[11]!=''){
print "&raquo; <a onclick=\"javascript:window.open('./umfrage/umfrage/ergebnisse.php?save=a6','Umfragen','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=600')\" return false; href=\"#\">
".$splitt[11]."</a><br />";
}

if($splitt[13]!=''){
print "&raquo; <a onclick=\"javascript:window.open('./umfrage/umfrage/ergebnisse.php?save=a7','Umfragen','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=600')\" return false; href=\"#\">
".$splitt[13]."</a><br />";
}

if($splitt[15]!=''){
print "&raquo; <a onclick=\"javascript:window.open('./umfrage/umfrage/ergebnisse.php?save=a8','Umfragen','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=600')\" return false; href=\"#\">
".$splitt[15]."</a><br />";
}

if($splitt[17]!=''){
print "&raquo; <a onclick=\"javascript:window.open('./umfrage/umfrage/ergebnisse.php?save=a9','Umfragen','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=600')\" return false; href=\"#\">
".$splitt[17]."</a><br />";
}

if($splitt[19]!=''){
print "&raquo; <a onclick=\"javascript:window.open('./umfrage/umfrage/ergebnisse.php?save=a10','Umfragen','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=600')\" return false; href=\"#\">
".$splitt[19]."</a><br />";
}
print "<br />
<a onclick=\"javascript:window.open('./umfrage/umfrage/ergebnisse.php','Umfragen','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=600')\" return false; href=\"#\">Ergebnis</a><br />";
?>
</body>
</html>
des javascript müsste weg aber wie ändere ich den code ?

ich hoffe ihr könnt mir helfen

mfg michib1979 :D

Re: umfrage ergebniss in die index.php

Verfasst: 06.02.2009 20:08
von kiwuff
Ähm.. extract($_POST), extract($_GET).. sicher dass Du das willst?
Wie der code aussehen sollte.. keine Ahnung, wie sieht denn ./umfrage/umfrage/ergebnisse.php aus?

Re: umfrage ergebniss in die index.php

Verfasst: 06.02.2009 20:38
von michib1979
Hier ist der code der ergebniss.php

Code: Alles auswählen

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Ergebnisse der aktuellen Umfrage</title>
<LINK href="style.css" rel="stylesheet">
</head>
<body>

<table cellpadding="4" cellspacing="1" width="500" class="border" align="center">
<tr>
<td class="title">

<?php
if(!empty($_GET)) { extract($_GET); }
else if(!empty($HTTP_GET_VARS)) { extract($HTTP_GET_VARS); }

if(!empty($_POST)) { extract($_POST); }
else if(!empty($HTTP_POST_VARS)) { extract($HTTP_POST_VARS); }

if(!empty($_COOKIE)) { extract($_COOKIE); }
else if(!empty($HTTP_COOKIE_VARS)) { extract($HTTP_COOKIE_VARS); }

if(!empty($_ENV)) { extract($_ENV); }
else if(!empty($HTTP_ENV_VARS)) { extract($HTTP_ENV_VARS); }

if(!empty($_SERVER)) { extract($_SERVER); }
else if(!empty($HTTP_SERVER_VARS)) { extract($HTTP_SERVER_VARS); }

if(!empty($_SESSION)) { extract($_SESSION); }
else if(!empty($HTTP_SESSION_VARS)) { extract($HTTP_SESSION_VARS); }

if(!empty($_FILES)) {
while(list($name, $value) = each($_FILES)) {
$$name = $value['tmp_name'];
}
} else if(!empty($HTTP_POST_FILES)) {
while(list($name, $value) = each($HTTP_POST_FILES)) {
$$name = $value['tmp_name'];
}
}
include("config.php");
$gewahlt=$_GET['save'];
$gelesen=fread(fopen("save.txt","r"),filesize("save.txt"));
$splitt=explode("¦",$gelesen);

if($gewahlt){
$iplist=fread(fopen("ips.txt","r"),filesize("ips.txt"));
$ip = $_SERVER['REMOTE_ADDR'];
$bol=strpos($iplist,$ip);
if(!$bol){
if($gewahlt=='a1'){
$splitt[2]++;
}
if($gewahlt=='a2'){
$splitt[4]++;
}
if($gewahlt=='a3'){
$splitt[6]++;
}
if($gewahlt=='a4'){
$splitt[8]++;
}
if($gewahlt=='a5'){
$splitt[10]++;
}
if($gewahlt=='a6'){
$splitt[12]++;
}
if($gewahlt=='a7'){
$splitt[14]++;
}
if($gewahlt=='a8'){
$splitt[16]++;
}
if($gewahlt=='a9'){
$splitt[18]++;
}
if($gewahlt=='a10'){
$splitt[20]++;
}
print "<b><span style=\"color:#00FF00\">Danke für deine Stimme!</span></b></td>
</tr><tr>
<td class=\"title\">";
$save=$splitt[0];
$save.='¦';
$save.=$splitt[1];
$save.='¦';
$save.=$splitt[2];
$save.='¦';
$save.=$splitt[3];
$save.='¦';
$save.=$splitt[4];
$save.='¦';
$save.=$splitt[5];
$save.='¦';
$save.=$splitt[6];
$save.='¦';
$save.=$splitt[7];
$save.='¦';
$save.=$splitt[8];
$save.='¦';
$save.=$splitt[9];
$save.='¦';
$save.=$splitt[10];
$save.='¦';
$save.=$splitt[11];
$save.='¦';
$save.=$splitt[12];
$save.='¦';
$save.=$splitt[13];
$save.='¦';
$save.=$splitt[14];
$save.='¦';
$save.=$splitt[15];
$save.='¦';
$save.=$splitt[16];
$save.='¦';
$save.=$splitt[17];
$save.='¦';
$save.=$splitt[18];
$save.='¦';
$save.=$splitt[19];
$save.='¦';
$save.=$splitt[20];
fwrite(fopen("save.txt","w"),$save);
$iplist.='¦';
$iplist.=$ip;
fwrite(fopen("ips.txt","w"),$iplist);
}ELSE{
print "<b><span style=\"color:red\">Sie haben bereits abgestimmt!</span></b></td>
</tr><tr>
<td class=\"title\">";
}
}


print "<b>".$splitt[0]."</b></td>
</tr><tr>
<td class=\"tablea\">";

$gesamt=$splitt[2]+$splitt[4]+$splitt[6]+$splitt[8]+$splitt[10]+$splitt[12]+$splitt[14]+$splitt[16]+$splitt[18]+$splitt[20];
if($gesamt!='0'){

if($splitt[1]!=''){
$prozent=(100/$gesamt)*$splitt[2];
$prozent=round($prozent,2);
print "<b>".$splitt[1]."</b></td>
</tr><tr>
<td class=\"tableb\"><img src=\"grafiken/balken.gif\" height=\"10\" width=\"$prozent*5%\"><br />
".$prozent."% (".$splitt[2]." Stimmen)</td>
</tr><tr>
<td class=\"tablea\">";
}

if($splitt[3]!=''){
$prozent=(100/$gesamt)*$splitt[4];
$prozent=round($prozent,2);
print "<b>".$splitt[3]."</b></td>
</tr><tr>
<td class=\"tableb\"><img src=\"grafiken/balken.gif\" height=\"10\" width=\"$prozent*5%\"><br />
".$prozent."% (".$splitt[4]." Stimmen)</td>
</tr><tr>
<td class=\"tablea\">";
}


if($splitt[5]!=''){
$prozent=(100/$gesamt)*$splitt[6];
$prozent=round($prozent,2);
print "<b>".$splitt[5]."</b></td>
</tr><tr>
<td class=\"tableb\"><img src=\"grafiken/balken.gif\" height=\"10\" width=\"$prozent*5%\"><br />
".$prozent."% (".$splitt[6]." Stimmen)</td>
</tr><tr>
<td class=\"tablea\">";
}

if($splitt[7]!=''){
$prozent=(100/$gesamt)*$splitt[8];
$prozent=round($prozent,2);
print "<b>".$splitt[7]."</b></td>
</tr><tr>
<td class=\"tableb\"><img src=\"grafiken/balken.gif\" height=\"10\" width=\"$prozent*5%\"><br />
".$prozent."% (".$splitt[8]." Stimmen)</td>
</tr><tr>
<td class=\"tablea\">";
}
if($splitt[9]!=''){
$prozent=(100/$gesamt)*$splitt[10];
$prozent=round($prozent,2);
print "<b>".$splitt[9]."</b></td>
</tr><tr>
<td class=\"tableb\"><img src=\"grafiken/balken.gif\" height=\"10\" width=\"$prozent*5%\"><br />
".$prozent."% (".$splitt[10]." Stimmen)</td>
</tr><tr>
<td class=\"tablea\">";
}

if($splitt[11]!=''){
$prozent=(100/$gesamt)*$splitt[12];
$prozent=round($prozent,2);
print "<b>".$splitt[11]."</b></td>
</tr><tr>
<td class=\"tableb\"><img src=\"grafiken/balken.gif\" height=\"10\" width=\"$prozent*5%\"><br />
".$prozent."% (".$splitt[12]." Stimmen)</td>
</tr><tr>
<td class=\"tablea\">";
}

if($splitt[13]!=''){
$prozent=(100/$gesamt)*$splitt[14];
$prozent=round($prozent,2);
print "<b>".$splitt[13]."</b></td>
</tr><tr>
<td class=\"tableb\"><img src=\"grafiken/balken.gif\" height=\"10\" width=\"$prozent*5%\"><br />
".$prozent."% (".$splitt[14]." Stimmen)</td>
</tr><tr>
<td class=\"tablea\">";
}

if($splitt[15]!=''){
$prozent=(100/$gesamt)*$splitt[16];
$prozent=round($prozent,2);
print "<b>".$splitt[15]."</b></td>
</tr><tr>
<td class=\"tableb\"><img src=\"grafiken/balken.gif\" height=\"10\" width=\"$prozent*5%\"><br />
".$prozent."% (".$splitt[16]." Stimmen)</td>
</tr><tr>
<td class=\"tablea\">";
}

if($splitt[17]!=''){
$prozent=(100/$gesamt)*$splitt[18];
$prozent=round($prozent,2);
print "<b>".$splitt[17]."</b></td>
</tr><tr>
<td class=\"tableb\"><img src=\"grafiken/balken.gif\" height=\"10\" width=\"$prozent*5%\"><br />
".$prozent."% (".$splitt[18]." Stimmen)</td>
</tr><tr>
<td class=\"tablea\">";
}

if($splitt[19]!=''){
$prozent=(100/$gesamt)*$splitt[20];
$prozent=round($prozent,2);
print "<b>".$splitt[19]."</b></td>
</tr><tr>
<td class=\"tableb\"><img src=\"grafiken/balken.gif\" height=\"10\" width=\"$prozent*5%\"><br />
".$prozent."% (".$splitt[20]." Stimmen)</td>
</tr><tr>
<td class=\"tablea\">";
}

}

print "".$gesamt." Stimme(n) gesamt.</td>
</tr><tr>
<td class=\"tableb\" align=\"right\"><a href=\"javascript:self.close()\"><b>zurück zu unser-fcb.de</b></a></td>";
?>
</tr>
</table>
ich hoffe der hilft dir weiter :D

Re: umfrage ergebniss in die index.php

Verfasst: 07.02.2009 13:59
von kiwuff
Äh... also ein paar Tips geb ich Dir, für den Rest musst Du aber schon noch selber ein wenig aktiv werden, gelle.
Der Code generiert 'ne komplette HTML-Seite.. das willst Du ja nicht, da Du das Teil ja einbinden willst in eine Seite.
Also brauchst Du den ganzen <html><head><body> -Krempel nicht... nur den direkt generierten Code darin. Also das, was zwischen <body> und </body> steht.
Ausserdem: nimm den ganzen extract-Kram raus. Vollkommen unnötig und unsicher. Wenn eine einzige Variable nicht initialisiert wird, kann Dir ein potentieller Angreifer damit sonstwas unterschieben.