<?php
session_start();
include('config.php');
$sitequery = 'select * from settings;';
$siteresult = mysql_query($sitequery,$connection) or die(mysql_error());
//Create site settings variables
$siteinfo = mysql_fetch_array($siteresult);
$sitetitle = $siteinfo['title'];
$siteurl = $siteinfo['url'];
$logo = $siteinfo['logourl'];
$statcode = $siteinfo['statcode'];
$username = $_POST['username'];
$email = $_POST['email'];
$password = md5($_POST['pWord']);
$fname = $_POST['fname'];
// Check captcha code
include_once ('securimage/securimage.php');
$securimage = new Securimage();
if ($securimage->check($_POST['captcha_code']) == false) {
// the code was incorrect
// you should handle the error so that the form processor doesn't continue
// or you can use the following code if there is no validation or you do not know how
header('Location: login.php?error=captcha');
exit;
}
// Confirm username and email are not duplicates
$checkformembers = mysql_query("SELECT * FROM authors WHERE username = '".$username."'");
$checkforemails = mysql_query("SELECT * FROM authors WHERE email = '".$email."'");
if(mysql_num_rows($checkformembers) != 0){
header('Location: login.php?error=user');
} elseif(mysql_num_rows($checkforemails) != 0){
header('Location: login.php?error=email');
} else {
$sql = "INSERT INTO authors VALUES ( NULL, 0, '".$email."', '".$username."', '".$password."',
'".$fname."', '".$fname."', NULL, NULL, 'http://www.gravatar.com/avatar/".md5(strtolower(trim($email)))."?d=".$siteurl."/images/avatar.png&s=90', 0);";
$query = mysql_query($sql);
header('Location: login.php?account=new');
exit();
}
?>