Location: PHPKode > scripts > PHP Hosting Directory > phphost_directoryv2/include/signup.php
<?

$years = array();
for ($i = 1990; $i <= date("Y"); $i++)
{
	array_push($years, $i);
}

if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
	$errors = array();

	if (trim($vars['username']) == '' || trim($vars['pwd']) == '' || trim($vars['email']) == '' || trim($vars['name']) == '' || trim($vars['address']) == '' || trim($vars['city']) == '' || trim($vars['state_province']) == '' || trim($vars['country']) == '' || trim($vars['zip_postal']) == '' || trim($vars['phone']) == '' || trim(str_replace("http://", "", $vars['company_url'])) == '' || trim($vars['month']) == '' || trim($vars['year']) == '')
	{
		array_push($errors, "Please make sure you've filled in all fields");
	}

	if (check_username($vars['username'])) {
		array_push($errors, "This username already exists");
	}

	if (check_company_url(str_replace("http://", "", $vars['company_url'])))
	{
		array_push($errors, "This company url already exists");
	}

	if (!check_email($vars['email'])) {
		array_push($errors, "Please make sure you've filled correct email");
	}

	if ($vars['nologo'] != 'on' && trim($_FILES['logo']['name']) == '') {
		array_push($errors, "Please provide logo for your company");
	}

	if (count($errors) == 0)
	{
		$sql = "INSERT INTO `hsl_host`
						(`username`,`pwd`,`email`,`name`,`address`,`city`,`state_province`,`country`,`zip_postal`,`phone`,`company_url`,`established`)
						VALUES (
						'".trim($vars['username'])."',
						'".trim($vars['pwd'])."',
						'".$vars['email']."',
						'".$vars['name']."',
						'".$vars['address']."',
						'".$vars['city']."',
						'".$vars['state_province']."',
						'".$vars['country']."',
						'".$vars['zip_postal']."',
						'".$vars['phone']."',
						'".str_replace("http://", "", $vars['company_url'])."',
						'".$vars['year']."-".$vars['month']."-01')";

		mysql_query($sql);
		$id = mysql_insert_id();
		
		if ($vars['nologo'] != 'on')
		{
			@unlink('logos/'.$id."_logo.gif");
			$fd = fopen("logos/".$id."_logo.gif", "wb");
			fwrite($fd, read_file($_FILES['logo']['tmp_name']));
			fclose($fd);
		}

		setcookie ("logged", $vars['username']);
		send_email($vars['email'], "letters/welcome.txt", read_file("letters/welcome_subj.txt"), $vars);
		java_redirect($config['base_url']."profile");
	}
	else
	{
		$t->assign('errors', $errors);
		$t->assign('old', $vars);
	}
}

$t->assign('years', $years);
$t->assign('main_html', $request[0].'.html');

?>
Return current item: PHP Hosting Directory