I am having a problem with the headers already being sent from my register.php and me trying to redirect to another page if the username and password are approved. Otherwise, the person could register for numerous passwords. Also, I would like to have the information that was initial sent to register.php as hidden no longer available once a username and password has been registered and they have been redirected. I am including a snippet of the code from my user.php and the register.php.
Any help would be gratly appreciated.
user.php
$sql="SELECT * FROM user WHERE user_name='$user_name'";
$result=db_query($sql);
if ($result && db_numrows($result) > 0) {
$feedback .= ' ERROR - USER NAME EXISTS ';
return false;
} else {
//create a new hash to insert into the db and the confirmation email
$hash=md5($email.$hidden_hash_var);
$sql="INSERT INTO user (user_name,real_name,password,email,remote_addr,confirm_hash,is_confirmed,streetaddress,streetaddress2,city,state,zipcode,shiptophone,szOrderNumber,accountnumber,month,year,transactionamount,donate_amount_rb) ".
"VALUES ('$donate_amount_rb','$streetaddress','$streetaddress2','$city','$state','$zipcode','$shiptophone','$szOrderNumber','$accountnumber','$month','$year','$transactionamount','$user_name','$real_name','". md5($password1) ."','$email','$GLOBALS[REMOTE_ADDR]','$hash','0')";
$result=db_query($sql);
if (!$result) {
$feedback .= ' ERROR - '.db_error();
return false;
} else {
//send the confirm email
user_send_confirm_email($email,$hash);
//$feedback .= ' Successfully Registered. You Should Have a Confirmation Email Waiting ';
//$feedback .= $success;
return true;
}
}
} else {
$feedback .= ' Account Name or Password Invalid ';
return false;
}
} else {
$feedback .= ' ERROR - Must Fill In User Name, Matching Passwords, And Provide Valid Email Address ';
return false;
}
}
register.php
<?php
include($DOCUMENT_ROOT.'/include/database.php');
include($DOCUMENT_ROOT.'/include/pre.php');
include($DOCUMENT_ROOT.'/include/user.php');
if (user_isloggedin()) {
user_logout();
$user_name='';
}
if ($submit) {
user_register($user_name,$password1,$password2,$email,$real_name,$streetaddress,$streetaddress2,$city,$state,$zipcode,$shiptophone,$szOrderNumber,$accountnumber,$month,$year,$transactionamount,donate_amount_rb);
}
if ($success) {
header("Location: http://www.whatever.cc/success.html");
exit;
}
site_header('Register With Charity Support Group');
if ($feedback) {
echo '<FONT COLOR="RED"><H2>'.$feedback.'</H2></FONT>';
}