Salve Ragazzi,volevo farvi una domanda.
Ho istallato uno script in phh login e pass.
Sembra tutto andare bene,l'unico problema che riscontro è che quando non inserisco nulla nel campo del form (join _form.php) e clicco su invio mi a questo errore:
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/xxxxxxxxxxx/domains/xxxxxxxxxxxxxxx.com/public_html/log_in/register.php:25) in /home/xxxxx/domains/xxxxxxxxxxxxxx.com/public_html/log_in/join_form.php on line 2.
Non riesco a capire dove possa essere l'errore.
QUESTO E' IL CONTENUTO DEL FILE REGISTER.PHP
<?php
include 'db.php';
// Define post fields into simple variables
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email_address = $_POST['email_address'];
$username = $_POST['username'];
$info = $_POST['info'];
/* Lets strip some slashes in case the user entered
any escaped characters. */
$first_name = stripslashes($first_name);
$last_name = stripslashes($last_name);
$email_address = stripslashes($email_address);
$username = stripslashes($username);
$info = stripslashes($info);
/* Do some error checking on the form posted fields */
if((!$first_name) || (!$last_name) || (!$email_address) || (!$username)){
echo 'Per entrare devi essere registato!</br>';
if(!$first_name){
echo "First Name is a required field. Please enter it below.</br>";
}
if(!$last_name){
echo "Last Name is a required field. Please enter it below.</br>";
}
if(!$email_address){
echo "Email Address is a required field. Please enter it below.</br>";
}
if(!$username){
echo "Desired Username is a required field. Please enter it below.</br>";
}
include 'join_form.php'; // Show the form again!
/* End the error checking and if everything is ok, we'll move on to
creating the user account */
exit(); // if the error checking has failed, we'll exit the script!
}
/* Let's do some checking and ensure that the user's email address or username
does not exist in the database */
$sql_email_check = mysql_query("SELECT email_address FROM users WHERE email_address='$email_address'");
$sql_username_check = mysql_query("SELECT username FROM users WHERE username='$username'");
$email_check = mysql_num_rows($sql_email_check);
$username_check = mysql_num_rows($sql_username_check);
if(($email_check > 0) || ($username_check > 0)){
echo "Please fix the following errors: </br>";
if($email_check > 0){
echo "[b]Your email address has already been registered by another member in our database. Please submit a different Email address!
";
unset($email_address);
}
if($username_check > 0){
echo "The username you have selected has already been registered by another member in our database. Please choose a different Username!
";
unset($username);
}
include 'index.html'; // Show the form again!
exit(); // exit the script so that we do not create this account!
}
/* Everything has passed both error checks that we have done.
It's time to create the account! */
/* Random Password generator.
http://www.phpfreaks.com/quickcode/R...nerator/56.php
We'll generate a random password for the
user and encrypt it, email it and then enter it into the db.
*/
function makeRandomPassword() {
$salt = "abchefghjkmnpqrstuvwxyz0123456789";
srand((double)microtime()*1000000);
$i = 0;
while ($i <= 7) {
$num = rand() % 33;
$tmp = substr($salt, $num, 1);
$pass = $pass . $tmp;
$i++;
}
return $pass;
}
$random_password = makeRandomPassword();
$db_password = md5($random_password);
// Enter info into the Database.
$info2 = htmlspecialchars($info);
$sql = mysql_query("INSERT INTO users (first_name, last_name, email_address, username, password, info, signup_date, decrypted_password)
VALUES('$first_name', '$last_name', '$email_address', '$username', '$db_password', '$info2', now(), '$random_password')") or die (mysql_error());
if(!$sql){
echo 'There has been an error creating your account. Please contact the webmaster.';
} else {
$userid = mysql_insert_id();
$activatepath = "activate.php?id=$userid&code=$db_password";
// Let's mail the user!
$subject = "Membership request at $sitename";
$message = "Dear $first_name $last_name,
You are now registered at our website, $sitepath
To activate your membership, please login here: $sitepath$activatepath
Once you activate your membership, you will be able to login with the following information:
Username: $username
Password: $random_password
Please keep this username and password in a location that is easily accessible by you.
Thanks!
Webmaster, $sitename
This is an automated response, please do not reply!";
mail($email_address, $subject, $message, "From: $sitename <$adminemail>\nX-Mailer: PHP/" . phpversion());
echo 'Your membership information has been mailed to your email address! Please check it and follow the directions!';
}
?>
QUESTO INVECE E' IL CONTENUTO DEL FILE JOIN_FORM.PHP
<?php
session_start();
if ($_SESSION['email_address'] != "" ) {
echo "You do not have the appropriate permissions to enter new distributors.
";
if ( empty( $first_name ) ) {
print "Please login below!";
include 'index.html';
}
} else { print "
Spero che qualcuno mi possa aiutare a risolvere questo errore.
Grazie