session_start();
include("panel/login1.php");
global $file_name;
$date = date("Y/m/d");
echo ""; ?>
Join To Our Mailing List
function valid_email($address)
{
// check an email address is possibly valid
if (ereg('^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$', $address))
return true;
else
return false;
}
function displayStatus(){
$uname = $_SESSION['reguname'];
if($_SESSION['regresult']){
echo "
Thank you!
".addslash($uname)." will be placed in our mailing list
.";
}
else{
echo "MySQL error. Please try again in a few minutes";
}
unset($_SESSION['reguname']);
unset($_SESSION['registered']);
unset($_SESSION['regresult']);
}
/**
Vraca true ako je korisnicko ime vec zauzeto.
*/
function usernameTaken($username){
global $conn;
if(!get_magic_quotes_gpc()){
$username = addslashes($username);
}
$q = "select email from users where email = '$username'";
$result = mysql_query($q,$conn);
return (mysql_numrows($result) > 0);
}
/**
* Inserts the given (username, password) pair
* into the database. Returns true on success,
* false otherwise.
*/
function addslash($theValue){
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
return $theValue;
}
function addNewUser($email, $dat, $pass, $act){
global $conn;
$q = "INSERT INTO users VALUES ('', '".addslash($email)."', '".addslash($pass)."', '".addslash($dat)."', '".addslash($act)."')";
return mysql_query($q,$conn);
}
/**
* Determines whether or not to show to sign-up form
* based on whether the form has been submitted, if it
* has, check the database for consistency and create
* the new account.
*/
if(isset($_POST['subjoin'])){
/* Make sure all fields were entered */
if(!$_POST['email']){
die('Please go back and type in your email address.');
}
if(!valid_email($_POST['email'])){
die('Email address isn\'t valid. Please check it again.');
}
/* Spruce up username, check length */
$_POST['email'] = trim($_POST['email']);
/* Check if username is already in use */
if(usernameTaken($_POST['email'])){
$use = $_POST['email'];
die("Email : $use is allready taken, please choose another one");
}
/* Add the new account to the database */
$_SESSION['reguname'] = $_POST['email'];
$_SESSION['regresult'] = addNewUser($_POST['email'], $date, "p", "Y");
$_SESSION['registered'] = true;
//echo "";
}
?>
if(isset($_SESSION['registered'])){
/**
* This is the page that will be displayed after the
* registration has been attempted.
*/
displayStatus();
}
?>