Y dónde está la suma de las dos fotos? Por qué tienes separados los dos .txt? Tienes ahí mil cosas xD
Ahí va:
Código PHP:
<?php
if ($_GET['enviar']) {
echo "<p><b>Gracias por votar</p>";
$file = "base.txt";
if(!file_exists($file)) { //si el txt no existe...
$fp=fopen($file,"w"); //creamos un txt por si no tá creado
fputs($fp,"0\n0\n0"); //le ponemos las respuestas desde 0
//1=1º foto; 2=2º foto; 3=votos
fclose($fp); //cerramos el txt
}
//incluimos el fichero config.php donde tenemos la configuración del script
$file=file($file); //creamos el array con las lineas del archivo
$file[0] += $_GET['foto1']; //votos 1º fotos
$file[1] += $_GET['foto2']; //votos 2º foto
$file[2]++; //cantidad de votos
$fp=fopen($file,"w+"); //abrimos de nuevo el txt borrándolo todo
fwrite($fp,$file[0]."\n".$file[1]."\n".$file[2]); //escribimos en el txt los votos.. en su respectiva línea. NOTA: \n <- cambia de línea ;)
fclose($fp); //cerramos el txt
}
?>
<form method="POST" action="">
<p><b>Foto 1</b> <select size="1" name="foto1">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select> <b>Foto 2 </b><select size="1" name="foto2">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select></p>
<p><input type="submit" value="Enviar" name="enviar"><input type="reset" value="Restablecer" name="B2"></p>
</form>
Ahora, si quieres saber cuál de los dos gana:
Código PHP:
<?php
$file = "base.txt";
$file=file($file); //creamos el array con las lineas del archivo
if ($file[0] > $file[1]) { $resultado = "Gana la foto 1"; }
elseif ($file[1] > $file[0]) { $resultado = "Gana la foto 2"; }
else { $resultado = "Empate"; }
$votos = $file[2];
$puntuacion1 = round($file[0]/$votos); //puntiacón de la foto 1
$puntuacion2 = round($file[1]/$votos); //puntuación de la foto 2
?>