<?php
$hostname_temp = "localhost";
$database_temp = "my_zappi"; //my_tuonick
$username_temp = "zappi"; //metti il tuo username
$password_temp = ""; //metti la tua password
$temp = mysql_pconnect($hostname_temp, $username_temp, $password_temp) or trigger_error(mysql_error(),E_USER_ERROR);
if(isset($_POST['submit'])){
if(trim(empty($_POST['nickname'])) OR
trim(empty($_POST['contatto'])) OR
trim(empty($_POST['descrizione'])) OR
trim(empty($_POST['data1'])) OR
trim(empty($_POST['data2'])) OR
trim(empty($_POST['data3'])) OR
trim(empty($_POST['sesso'])))
trim(empty($_POST['regione'])){
echo '<script type="text/javascript">alert("Errore! Sei sicuro di aver compilato tutti i campi del form?")</script>';
}elseif(!eregi("^[a-z0-9][_\.a-z0-9-]+@([a-z0-9][0-9a-z-]+\.)+([a-z]{2,4})", $_POST['contatto'])){
echo "Errore! Non hai inserito un indirizzo email valido!";
}elseif{
$query = "SELECT Count( * ) AS Conta FROM n_user WHERE nickname = '$_POST[nickname]'";
$raw = mysql_query($query);
$row = mysql_fetch_array($raw);
$raw.close;
if($row[Conta]>0){
echo '<script type="text/javascript">alert("Nickname Gia Esiste!!")</script>';
}elseif{
$query = "SELECT Count( * ) AS Conta FROM n_user WHERE contatto = '$_POST[contatto]'";
$raw = mysql_query($query);
$row = mysql_fetch_array($raw);
$raw.close;{
if($row[Conta]>0 ){
echo '<script type="text/javascript">alert("Contatto Gia esiste!!")</script>';
}else{
mysql_select_db($database_temp, $temp);
$query_prova1 = "INSERT INTO contatti_msn (nickname, contatto, descrizione, data1, data2, data3, sesso, regione, citta, interessi) VALUES ('".$_POST['nickname']."', '".$_POST['contatto']."', '".$_POST['descrizione']."', '".$_POST['data1']."', '".$_POST['data2']."', '".$_POST['data3']."', '".$_POST['sesso']."', '".$_POST['regione']."', '".$_POST['citta']."', '".$_POST['interessi']."')";
if(!($prova1 = mysql_query($query_prova1, $temp))){
die(mysql_error());}
//$row_prova1 = mysql_fetch_assoc($prova1);
//$totalRows_prova1 = mysql_num_rows($prova1);
mysql_close($temp);
echo '<script type="text/javascript">alert("Dati Salvati!!")</script>';}?>