alla fine del sito, dopo aver mantenuto determinati dati attraverso una sessione, decido di far registrare l'utente quindi:
<?php
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<p align="left">
<title>prueba emociones</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p align="center"> <font size="+4">
values
<html>
<head>
<title>Iscriviti</title>
</head>
<body>
<form action="register2.php" method="POST" name="register">
Username<input type="text" name="username">
Password<input type="password" name="password">
Verifica password<input type="password" name="repassword">
<input type="submit" value="Iscriviti">
</body>
</html>
<?php
$_SESSION['test_valence_photo10'] = $_GET['test_valence_photo10'];
?>
poi l'utente si registra e vorrei che inserisca tutto nel database, compresi i dati di sessione, quindi gli dico che le variabili di sessione che ho portato avanti con $_GET vengano immesse nel database con $_SESSION e il nome di ogni variabile, pero' vorrei inserire anche le utlime due variabili passate con $_POST della registrazione quindi:
. $_POST['username']. "','" . $_POST['password'].
alla fine pero' di tutto, mi dice che l query è vuota.
<?php
session_start();
?>
<?
include "config.php";
// inizializza sempre le variabili che usi in uno script
$username="";
$psw="";
$repsw="";
// assegna i valori POSTati a queste variabili hashando la password
$username=$_POST['username'];
$psw=md5($_POST['password']);
$repsw=md5($_POST['repassword']);
$ver = "SELECT * FROM messaggi WHERE username= '$username'";
$tabver = @mysql_query ($ver) or die (mysql_error());
$veruser = mysql_num_rows ($tabver);
if ($username=='' || $psw=='' || $repsw=='')
{
echo '
Compila correttamente tutti i campi';
}
else if ($psw !== $repsw)
{
echo "
Controllare la password digitata.";
}
else if ($veruser !== 0)
{
echo "
L'username richiesto risulta già registrato";
}
else if (eregi("[:,;èéçòà =()]", $username))
{
echo "
Il nick contiene caratteri non validi.";
}
else
{
$inserimento=mysql_query( "insert into messaggi (id_user,username,password,user,gender,date_of_bir th,country,test_arousal_photo1,test_valence_photo1 ,test_arousal_photo2,test_valence_photo2,test_arou sal_photo3,test_valence_photo3,test_arousal_photo4 ,test_valence_photo4,test_arousal_photo5,test_vale nce_photo5,test_arousal_photo6,test_valence_photo6 ,test_arousal_photo7,test_valence_photo7,test_arou sal_photo8,test_valence_photo8,test_arousal_photo9 ,test_valence_photo9,test_arousal_photo10,test_val ence_photo10,date) values ('" . $_POST['username']. "','" . $_POST['password']. "','" . $_SESSION['id_user']. "', '" . $_SESSION['user']. "','" . $_SESSION['gender'] . "','" . $_SESSION['year'] . "-" . $_SESSION['month'] . "-" . $_SESSION['day'] . "','" . $_SESSION['country'] . "','" . $_SESSION['test_arousal_photo1'] . "','" . $_SESSION['test_valence_photo1'] . "','" . $_SESSION['test_arousal_photo2'] . "','" . $_SESSION['test_valence_photo2'] . "','" . $_SESSION['test_arousal_photo3'] . "','" . $_SESSION['test_valence_photo3'] . "','" . $_SESSION['test_arousal_photo4'] . "','" . $_SESSION['test_valence_photo4'] . "','" . $_SESSION['test_arousal_photo5'] . "','" . $_SESSION['test_valence_photo5'] . "','" . $_SESSION['test_arousal_photo6'] . "','" . $_SESSION['test_valence_photo6'] . "','" . $_SESSION['test_arousal_photo7'] . "','" . $_SESSION['test_valence_photo7'] . "','" . $_SESSION['test_arousal_photo8'] . "','" . $_SESSION['test_valence_photo8'] . "','" . $_SESSION['test_arousal_photo9'] . "','" . $_SESSION['test_valence_photo9'] . "','" . $_SESSION['test_arousal_photo10'] . "','" . $_SESSION['test_valence_photo10'] . "', now())" );
$query= @mysql_query($sql) or die (mysql_error());
echo "
Registrazione effettuata.";
}
@mysql_close($connection);
?>
</body>
</html>
come correggo lo script di inserimento?
grazie