<?php
/* Copyright (c) 2001-02 by Ken Williams (hide@address.com)*/
/* http://phpfastnews.sourceforge.net/ & http://www.phpfastnews.com*/
/* */
/* You can redistribute and/or modify the following code under the */
/* terms of the GNU General Public License as published by the */
/* the Free Software Foundation. */
/* */
/* All code by Ken Williams (HDwebdev) unless otherwise noted */
/* This is an alpha test release -- not intended for live site use */
$pg = "news_index";
$tpl = "news.tpl";
require('Lib/prependphpfn.php');
$r->set_block('TPL','USER_REGISTER');
if ($submit)
{
$query = "select email from ps_auth_user where '$email' = email";
$db->query($query);
if ($db->f("email") == $email) {
$error_form = "Email address already in use. Please choose another.<br>";
$email = '';
}
if (!email_validate($email)) {
$error_form = "That is not a valid email format, please check the address.<br>";
}
$query = "select handle,username from fn_user,ps_auth_user where ('$username2' = handle)
or ('$username2' = username)";
$db->query($query);
if ($db->f("handle") == $username2 || $db->f("username") == $username2) {
$error_form .= "Handle already in use. Please choose another<br>";
}
if (!strlen($password)) {
$error_form .= "You must enter a password.<br>";
$password = $password_2 = '';
}
if (!($password == $password_2)) {
$error_form .= "Passwords do not match. Please re-enter them<br>";
$password = $password_2 = '';
}
if (!$error_form && $submit) {
$user_id=$db->nextid("user_id");
$password = md5($password);
$timestamp = time();
$query = "insert into ps_auth_user values('$user_id', '$username2', '$password', '$email',
'Y', '$timestamp','$timestamp', '', '', '', '')";
$db->query($query);
$query = "insert into fn_user values ('$user_id', '$username2', '', '', '')";
$db->query($query);
$query = "insert into fn_user2 values ('$user_id', '$email','','','','','','','','','','','','','')";
$db->query($query);
$query = "insert into ps_user_group_xref values ('$user_id','4')";
$db->query($query);
$last_page = "news_index.php";
echo "You may now login with that username and password";
echo "<form action=user_login.php method=post>
<input type=submit name=Submit value=Login>
</form>";
exit;
}
}
$r->set_var(array(
"error_form" => $error_form,
"handle" => $username2,
"email" => $email,
"labelTITLE" => "Registration"
));
$r->parse('body','USER_REGISTER',true);
require('Lib/appendphpfn.php');
?>