Location: PHPKode > projects > PHPOLL php - mysql poll system > phpoll_files/admin/band_editor.php
<!--

This file is part of PHPOLL.

    PHPOLL is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    PHPOLL is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with PHPOLL; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

-->

<?php

if (isset ($_GET['language'])) { 
	$language=(int)$_GET['language'];
}

else {
	$language=1;
}

if ($language==0) {

  die ("Try a different way!");

}

include "../config/config.php";
include "localization.php";

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>


<script type="text/javascript" language="JavaScript">
<!--

function submitForm () {
	
	var answer = confirm ("<?php print $config_alert_conferma; ?>");
  
		if (answer) {
			window.document.modifica_band.submit();
		}
		else {
			alert ("<?php print $config_alert_annulla; ?>");
		}
		
}

function submitFormInserisci () {
	
	window.document.inserisci_band.submit();
		
}

//-->
</script>

<title>PHPOLL - editor candidati</title>
<link rel="stylesheet" href="../css/phpoll_layout.css" title="phpoll layout" />
</head>
<body>

<div class="corpo">

<img src="../img/poll_logo.jpg" alt="phpoll logo" />
<img src="../main_img/phpoll_char.gif" alt="phpoll" />

<br />

<a href="config_editor.php?language=1"><img src="../img/ita.jpg" alt="italiano" /></a>
<a href="config_editor.php?language=2"><img src="../img/eng.jpg" alt="english" /></a>

<br />

<?php

print "<div class=\"titolo_db\">";
print "POLL: ".$prepoll;
print "&nbsp;&nbsp;&nbsp;IP: ".$_SERVER['REMOTE_ADDR'];
print "</div>";

?>

<div class="menu">

<?php 

print "<a href=\"config_editor.php?language=".$language."\">".$admin_menu_config."</a>";
print "<a class=\"attuale\" href=\"band_editor.php\">".$admin_menu_candidati."</a>";
print "<a href=\"votanti.php?language=".$language."\">".$admin_menu_voti."</a>";
print "<a href=\"risultati_config.php?language=".$language."\">".$admin_menu_risultati."</a>";

?>

</div>

<div class="forms">

<?php

// assegno le variabili di connessione
$phpoll_db = mysql_connect ($phpoll_host, $phpoll_user, $phpoll_password)
	or die ("Errore nella connessione a MySQL");
	
// selezione del database
mysql_select_db($phpoll_database, $phpoll_db)
	or die ("Errore nella connessione al database ".$phpoll_database);
	
// QUERY per MySQL
$query_band = "SELECT * FROM ".$tab_band." ORDER BY nome_band;";

$estrai_band = mysql_query($query_band, $phpoll_db)
	or die ("Errore nella connessione per estrazione nomi band al database ".$phpoll_database);
	
// QUERY per MySQL
$query_login = "SELECT login, password FROM phpoll_".$prepoll."_configurazione;";	
	
$estrai_login = mysql_query($query_login, $phpoll_db)
	or die ("Errore nella connessione per estrazione login configurazione dal database ".$database);
	
$string_cook_login = "phpoll_".$prepoll."_login";
$string_cook_password = "phpoll_".$prepoll."_password";	
	
while ($dati_login=mysql_fetch_assoc ($estrai_login)) {
	
	$log=$dati_login['login'];
	$pw=$dati_login['password'];

	if ($log!="admin"&&$pw!="admin") {

	if ((isset($_COOKIE[$string_cook_login])&&$log==$_COOKIE[$string_cook_login])&&(isset($_COOKIE[$string_cook_password])&&$pw==$_COOKIE[$string_cook_password])) {
		
		$test_log = true;
		
	}
	
	else {
		
		$test_log = false;
		
	}
	
	}
	
	else {
		
		$test_log = true;
		
	}		

}

if ($test_log) {	
	
	
print "<div class=\"band\">";

print "<form action=\"modifica_band.php?language=".$language."&nuova_band=1\" method=\"post\" name=\"inserisci_band\">";

print "<table border=\"1\">";
print "<tr id=\"band_titoli\">";
print "<td>".$titolo_tipologia."</td>";	
print "<td>".$titolo_punteggio."</td>";
print "</tr>";

print "<tr>";

print "<td>";
print "<input type=\"text\" name=\"nome_band\" size=\"60\" />";
print "</td>";
print "<td>";
print "<input type=\"text\" name=\"voti\" size=\"7\" />";
print "</td>";

print "</tr>";

print "</table>";

print "<a href=\"#\" onClick=\"submitFormInserisci();\"><img src=\"../img/ins.png\" alt=\"".$config_inseriscirecord."\" /> ".$config_inseriscirecord." ".$titolo_tipologia."</a>";
//print "<input type=\"submit\" name=\"submit_nuova\" value=\"inserisci nuova band\" />";

print "</form>";

print "</div>";

print "<div class=\"band\">";	

print "<form onSubmit=\"return cancella();\" action=\"modifica_band.php?language=".$language."\" method=\"post\" name=\"modifica_band\">";

print "<table border=\"1\">";
print "<tr id=\"band_titoli\">";
print "<td>".$titolo_tipologia."</td>";	
print "<td>".$titolo_punteggio."</td>";
print "<td><img src=\"../img/gomma.gif\" alt=\"cancella\" /></td>";		
print "</tr>";

$i=0;	
while ($dati_band=mysql_fetch_assoc ($estrai_band)) {

	print "<tr>";
		print "<td>";
			print "<input type=\"text\" name=\"nome_band_".$i."\" value=\"".$dati_band['nome_band']."\" size=\"60\" />";
		print "</td>";
		print "<td>";
			print "<input type=\"text\" name=\"voti_".$i."\" value=\"".$dati_band['voti']."\" size=\"7\" />";
		print "</td>";
		print "<td>";
		print "<input type=\"checkbox\" name=\"check_".$i."\" />";
		print "</td>";
		print "<input type=\"hidden\" name=\"id_".$i."\" value=\"".$dati_band['id']."\" />";
	print "</tr>";
	
	$i++;

}

print "</table>";

print "<a href=\"#\" onClick=\"submitForm();\"><img src=\"../img/disk.gif\" alt=\"".$config_salvamodifiche."\" /> ".$config_salvamodifiche."</a>";
//print "<input type=\"submit\" name=\"submit\" value=\"conferma modifica\" />";
print "</form>";

print "</div>";

mysql_close ($phpoll_db);

}

else {
	
	print "<form action=\"elabora_cookie.php\" method=\"post\" name=\"form_elabora\">";
	print "<table align=\"center\">";
	print "<tr>";
	print "<td>login</td>";
	print "<td>";
	print "<input type=\"text\" name=\"log\" size=\"30\" />";
	print "</td>";
	print"</tr><tr>";
	print "<td>password</td>";
	print "<td>";
	print "<input type=\"password\" name=\"pw\" size=\"30\" />";
	print "</td>";
	print "</tr></table>";
	print "<input type=\"submit\" name=\"submit\" value=\"".$config_conferma."\" />";
	print "</form>";
		
	
}

?>

</div>
</div>



</body>
</html>
Return current item: PHPOLL php - mysql poll system