codice:
<?php require_once('Connections/palestra.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
function converti($drmdata)
{
$giorno_conv=substr($drmdata,0,2);
$mese_conv=substr($drmdata,3,2);
$anno_conv=substr($drmdata,6,4);
$drmdata=$anno_conv."-".$mese_conv."-".$giorno_conv;
return $drmdata;
}
$_POST['data_nascita']=converti($_POST['data_nascita']);
$_POST['data_iscrizione']=converti($_POST['data_iscrizione']);
$_POST['scadenza_iscrizione_annuale']=converti($_POST['scadenza_iscrizione_annuale']);
$_POST['scadenza_mensile']=converti($_POST['scadenza_mensile']);
$_POST['scadenza_certificato']=converti($_POST['scadenza_certificato']);
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO palestra (numero_tessera_socio, cognome, nome, data_nascita, codice_fiscale, residente, città, telefono, cellulare, scadenza_mensile, attività, acqua_gim, certificato, note, scadenza_certificato, sponsor, assicurazione, email) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['numero_tessera_socio'], "text"),
GetSQLValueString($_POST['cognome'], "text"),
GetSQLValueString($_POST['nome'], "text"),
GetSQLValueString($_POST['data_nascita'], "text"),
GetSQLValueString($_POST['codice_fiscale'], "text"),
GetSQLValueString($_POST['residente'], "text"),
GetSQLValueString($_POST['città'], "text"),
GetSQLValueString($_POST['telefono'], "text"),
GetSQLValueString($_POST['cellulare'], "text"),
GetSQLValueString($_POST['scadenza_mensile'], "date"),
GetSQLValueString($_POST['attività'], "text"),
GetSQLValueString($_POST['acqua_gim'], "text"),
GetSQLValueString($_POST['certificato'], "text"),
GetSQLValueString($_POST['note'], "text"),
GetSQLValueString($_POST['scadenza_certificato'], "date"),
GetSQLValueString($_POST['sponsor'], "text"),
GetSQLValueString($_POST['assicurazione'], "text"),
GetSQLValueString($_POST['email'], "text"));
mysql_select_db($database_palestra, $palestra);
$Result1 = mysql_query($insertSQL, $palestra) or die(mysql_error());
}
mysql_select_db($database_palestra, $palestra);
$query_Recordset1 = "SELECT * FROM palestra,piscina ";
$Recordset1 = mysql_query($query_Recordset1, $palestra) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
mysql_select_db($database_palestra, $palestra);
$query_Recordset2 = "SELECT * FROM piscina";
$Recordset2 = mysql_query($query_Recordset2, $palestra) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
?><!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento senza titolo</title>
<style type="text/css">
<!--
.Stile1 {
font-size: 24px;
font-weight: bold;
color: #0000FF;
}
.style56 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; }
.Stile2 {font-size: 18px}
body {
background-color: #CCFF66;
}
-->
</style>
</head>
<script language="javascript" src="cal2.js">
/*
Xin's Popup calendar script- Xin Yang (http://www.yxscripts.com/)
Script featured on/available at http://www.dynamicdrive.com/
This notice must stay intact for use
*/
</script>
<script language="javascript" src="cal_conf2.js"></script>
<body>
<script>
function CheckIscritti(n)
{
if(n>10) {
window.alert("Numero massimo iscritti Acqua Gym raggiunto");
}
}
</script>
<?php
//$conteggio = "SELECT COUNT( numero_tessera_socio ) AS totale from piscina WHERE numero_tessera_socio = '$numero_tessera_socio' ";
//$queryconteggio=mysql_query($conteggio);
//if($queryconteggio)
//$totale = mysql_result($queryconteggio,0,'totale');
//echo($totale);
?>
<?php
$query = "SELECT COUNT(numero_tessera_socio) AS totale FROM piscina ";
$result = mysql_query($query);
$righe = mysql_fetch_row($result);
$iscritti_agym = $righe[0];
echo($result);
?>
<?php //echo $totalRows_Recordset2?>
<?php //if ($totalRows_Recordset2>=10) { echo " <p align='center' >ATTENZIONE!!!
I PARTECIPANTI AD ACQUA GIM SONO GIA 10: </p>";
// }
?>
<?php if ($_POST['acqua_gim'] == 'Y')
{
$queryA = "insert into piscina (numero_tessera_socio,cognome,nome,acqua_gim)
select palestra.numero_tessera_socio,palestra.cognome,palestra.nome,palestra.acqua_gim
from palestra WHERE numero_tessera_socio = '$numero_tessera_socio'";
mysql_select_db($database_palestra, $palestra);
$Result1 = mysql_query($queryA, $palestra) or die(mysql_error());
}
?>
<div align="center" class="Stile1"><u>[img]immagini/sp75.gif[/img]<span class="Stile2">INSERISCI NUOVO SOCIO</span></u>[img]immagini/sp75.gif[/img]</div>
<form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<table width="1018" height="364" border="0" align="center">
<tr>
<td width="92" height="69"><div align="center">Numero Tessera Cliente </div></td>
<td width="144"><label>
<input name="numero_tessera_socio" type="text" id="numero_tessera_socio" />
</label></td>
<td width="72"><div align="center">Cognome</div></td>
<td width="144"><label>
<input name="cognome" type="text" id="cognome" />
</label></td>
<td width="66"><div align="center">Nome</div></td>
<td width="144"><label>
<input name="nome" type="text" id="nome" />
</label></td>
<td width="59"><div align="center">Data Nascita </div></td>
<td width="173"><label><span class="style56">Seleziona Data
Nascita </span>
<input name="data_nascita" type="text" id="data_nascita" />
</label></td>
</tr>
<tr>
<td height="48"><div align="center">Codice Fiscale </div></td>
<td><label>
<input name="codice_fiscale" type="text" id="codice_fiscale" />
</label></td>
<td><div align="center">Residente Via </div></td>
<td><label>
<input name="residente" type="text" id="residente" />
</label></td>
<td><div align="center">Città</div></td>
<td><label>
<input name="città" type="text" id="città" />
</label></td>
<td><div align="center">Telefono</div></td>
<td><label>
<input name="telefono" type="text" id="telefono" />
</label></td>
</tr>
<tr>
<td height="54"><div align="center">Cellulare</div></td>
<td><label>
<input name="cellulare" type="text" id="cellulare" />
</label></td>
<td><div align="center">Data Iscrizione</div></td>
<td><?php echo date('d-m-Y H:i',time());?></td>
<td><div align="center">Scadenza Mensile</div></td>
<td><label><span class="style56">Seleziona Scadenza Mensile </span>
<input name="scadenza_mensile" type="text" id="scadenza_mensile" />
</label></td>
<td><div align="center">Attività</div></td>
<td><label>
<textarea name="attività" id="attività"></textarea>
</label></td>
</tr>
<tr>
<td height="113"><div align="center">Acqua Gim </div></td>
<td><table width="79" height="15">
<tr>
<td width="71" height="15"><INPUT onclick="CheckIscritti(<?=$iscritti_agym?> )" input type="radio" name="acqua_gim" value="Y" <?php if (!(strcmp($row_Recordset1['acqua_gim'],"Y")))?> />
[ SI ]
</p> </td>
</tr>
<tr>
<td height="24"><input type="radio" name="acqua_gim" value="N" <?php if (!(strcmp($row_Recordset1['acqua_gim'],"N")))?> />
[ NO ]</td>
</tr>
</table>
</td>
<td height="113"><div align="center">Certificato</div></td>
<td><table width="79" height="15">
<tr>
<td width="71" height="15"><input type="radio" name="certificato" value="Y" <?php if (!(strcmp($row_Recordset1['certificato'],"Y")))?> />
[ SI ]
</p>
</td>
</tr>
<tr>
<td height="24"><input type="radio" name="certificato" value="N" <?php if (!(strcmp($row_Recordset1['certificato'],"N")))?> />
[ NO ]</td>
</tr>
</table></td>
<td><div align="center">Scadenza Certificato</div></td>
<td><span class="style56">Seleziona Scadenza Certificato </span>
<input name="scadenza_certificato" type="text" id="scadenza_certificato" /></td>
<td><div align="center">Sponsor</div></td>
<td><table width="79" height="56">
<tr>
<td width="71" height="24"><input type="radio" name="sponsor" value="Y" <?php if (!(strcmp($row_Recordset1['sponsor'],"Y")))?> />
[ SI ]
</p>
</td>
</tr>
<tr>
<td height="24"><input type="radio" name="sponsor" value="N" <?php if (!(strcmp($row_Recordset1['sponsor'],"N")))?> />
[ NO ]</td>
</tr>
</table></td>
</tr>
<tr>
<td><div align="center">Note</div></td>
<td><label>
<textarea name="note" id="note"></textarea>
</label></td>
<td height="58"><div align="center">Assicurazione</div></td>
<td><table width="79" height="15">
<tr>
<td width="71" height="24"><input type="radio" name="assicurazione" value="Y" <?php if (!(strcmp($row_Recordset1['assicurazione'],"Y")))?> />
[ SI ]
</p> </td>
</tr>
<tr>
<td height="24"><input type="radio" name="assicurazione" value="N" <?php if (!(strcmp($row_Recordset1['assicurazione'],"N")))?> />
[ NO ]</td>
</tr>
</table></td>
<td><div align="center">E-Mail</div></td>
<td><label>
<input name="email" type="text" id="email" />
</label></td>
<td></td>
<td></td>
</tr>
</table>
<div align="center">
<input type="hidden" name="MM_insert" value="form1">
</div>
<label>
<div align="center">
<input type="submit" name="Submit" value="INSERISCI" />
</div>
</label>
</form>
</p>
</body>
</html>
<?php
mysql_free_result($Recordset1);
mysql_free_result($Recordset2);
?>