Hallo,
bin noch in den Anfangsschuhen von php, hab ein Votingscript, dass auch funktioniert, leider wird, wenn man seine Stimme abgibt diese nicht angezeigt, sondern es bleibt bei 1.
	
und er gibt folgende Notice:  Undefined index:  on, dies wär
	
bitte um Hilfe, danke im voraus
schischi
					bin noch in den Anfangsschuhen von php, hab ein Votingscript, dass auch funktioniert, leider wird, wenn man seine Stimme abgibt diese nicht angezeigt, sondern es bleibt bei 1.
PHP Code:
	
	
error_reporting(E_ALL);
    if(isset($_POST['vote-eins']))  $vote_eins  = $_POST['vote-eins'];
    if(isset($_POST['vote-zwei']))  $vote_zwei  = $_POST['vote-zwei'];
         $file = "votes.txt"; // Name der Textdatei in dem gleichen Ordner
         
         $title = "Wildthinx Reunion!?! Vielleicht haben wir eine Chance.<br /> Bitte stimmt ab!"; // Title
                                                      
         $answers = array('Ich bin dafür!', 'Nein, bitte nicht!'); // Text hinter den Radiobuttons
    echo '<h3>'. $title .'</h3>';
        echo '<p>';
            echo' <form name="voting" action="'.$_SERVER['PHP_SELF'].'" method="post">';
                    echo'<input type="radio" name="vote-eins">'.$answers[0].'<br />';
                    echo'<input type="radio" name="vote-zwei">'.$answers[1].'<br />';
                echo'<p><input type="submit" value="eintragen" name="eintragen"></p>';
            echo'</form>';
  
if (empty($_POST['vote-eins']) && empty($_POST['vote-zwei']))
{
    echo'Bitte auswaehlen';
}
else
{
echo'</p>';
echo'<h3>Ergebnis</h3>';
echo'<p>';
  //lese von der Textdatei
  $votes = file($file);
  $total = 0;
 
  //submit vote
  if(isset($vote_eins)){
    $votes[$vote_eins] = $votes[$vote_eins]+1;
  }
  
  //schreibe in die Textdatei
  $handle = fopen($file,"w");
  foreach($votes as $v){
    $total += $v;
    fputs($handle,chop($v)."\n");
  }
  fclose($handle);
  //print votes
  
    for($i=0;$i<count($answers[0]);$i++){
    echo "{$votes[$i]} Besucher sagten: {$answers[0]}<br />";
  }
  
      for($i=0;$i<count($answers[0]);$i++){
    echo "{$votes[$i]} Besucher sagten: {$answers[1]}<br />";
  }
 
echo'</p>';
echo'<p> Total: '.$total.' votes.</p>';
echo'</div>';
echo'</div>';
} 
PHP Code:
	
	
    $votes[$vote_eins] = $votes[$vote_eins]+1; 
schischi
 
          
 Moderatorin
 Moderatorin


Comment