Location: PHPKode > projects > Dominant Creature RPG > register.php
<?php
session_start();
include 'database.php';
?>
<HTML>
<HEAD>
<TITLE>Dominant Evil</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<SCRIPT SRC="class/boxover.js"></SCRIPT>
<style>
body {
background: #1E1E1E url(images/index_01.jpg) top repeat-x;
color: #fff;
font-size: 11px;
font-family: Verdana;
}

td {
color: #fff;
font-size: 11px;
font-family: Verdana;
}

#foot {
color: #fff;
font-size: 11px;
font-family: Verdana;
width: 808px;
height: 24px;
background: #1E1E1E url(images/footbg.jpg) top center repeat-x;
}

a, a:visited {
color: #D9C5C5;
font-weight: bold;
text-decoration: none;
}

a:hover, a:active {
color: #fff;
font-weight: bold;
text-decoration: none;
}

#head {
background: #1E1E1E url(images/index_02.jpg) no-repeat;
width: 808px;
height: 154px;
font-size: 11px;
font-family: Verdana;
}

#menu {
background: #1E1E1E url(images/index_04.jpg) no-repeat;
width: 808px;
height: 30px;
font-size: 11px;
font-family: Verdana;
padding-top: 6px;
padding-left: 16px;
}

#body {
background: #1E1E1E url(images/index_05.jpg) repeat-y;
width: 580px;
height: 500px;
font-size: 11px;
font-family: Verdana;
padding-top: 10px;
padding-left: 20px;
}

#body-right {
background: #1E1E1E url(images/index_06.jpg) repeat-y;
width: 208px;
height: 500px;
font-size: 11px;
font-family: Verdana;
}

input, select {
font-size: 11px;
}

</style>

</HEAD>
<BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>
<!-- ImageReady Slices (psd.psd) -->
<TABLE align=center width='808' BORDER=0 CELLPADDING=0 CELLSPACING=0>
	<TR>
		<TD colspan='2' valign='top' id='head'>
		</TD>
	</TR>
	<TR>
		<TD colspan='2' valign='top' id='menu'>
<a href='index.php'>Homepage</a> | <a href='register.php'>Join the game</a> | <a href='resend.php'>Lost pass?</a>

		</TD>
	</TR>
	<TR>
		<TD valign='top' align='left' id='body'>
<?
if (isset($_POST['submit']))
{

	$gameurl = "http://evil.bbgdev.com"; // with no trailing slash
	
	$first = addslashes(trim($_POST['firstname']));
	$username = addslashes(trim($_POST['username']));
	$email = addslashes(trim($_POST['email']));
	$pass = addslashes(trim($_POST['password']));
	$conf = addslashes(trim($_POST['confirm']));
	
	$ip = $_SERVER['REMOTE_ADDR'];
	$date = date("d, m y");
	
	if ( $_POST['password'] == $_POST['confirm'] )
	{}else{
	
		echo '<script>alert("Password not confirmed.");</script>';
		echo '<script>history.back(1);</script>';
		exit;
	
	}
	
	$password = md5($pass);
	
	if ((((( empty($first) ) || ( empty($username) ) || ( empty($email) ) || ( empty($password) )))))
	{
	
		echo '<script>alert("One or more fields were not submited. Please enter all fields.");</script>';
		echo '<script>history.back(1);</script>';
		exit;

	}
	
	if((!strstr($email , "@")) || (!strstr($email , ".")))
	{
	
		echo '<script>alert("You have entered non-valid email adress. Please try again.");</script>';
		echo '<script>history.back(1);</script>';
		exit;

	}
	
	$q = mysql_query("SELECT * FROM users WHERE user = '$username'") or die(mysql_error());
	if(mysql_num_rows($q) > 0)
	{
	
		echo '<script>alert("Username has already been taken. Please enter unique username.");</script>';
		echo '<script>history.back(1);</script>';
		exit;
			
	}
	
	$name = $first;
	$actkey = mt_rand(1, 500).'f78dj899dd';
	$act = sha1($actkey);
	$now = time();
	$query = mysql_query("
	INSERT INTO users 
	(
	id, 
	user,
	pass, 
	email, 
	date, 
	IP, 
	actkey,
	lang,
	turns,
	ref_time,
	ref_count
	) VALUES 
	(
	'',
	'$username',
	'$password',
	'$email',
	'$date',
	'$ip',
	'$act',
	'en',
	'120',
	'$now',
	'0'
	)") or die(mysql_error());
	$send = mail($email , "Registration confirmation" , "Thank you for
your registration.\n\nYour account details are located below along with
instructions on how to activate your account.\n\nYour username: ".$username."\nYour password: ".$pass."\n\nClick on a link below to activate your account:\n$gameurl/activate.php?id=".$act."\n\nThank you once again.\n\n Dominant Evil", "FROM: hide@address.com");
	
	if(($query)&&($send))
	{
	
		echo '	<html>
				<head>
				<title>Registration succesful</title>
				</head>
				
				<body>
				
				<div>
				<p>Thank you for your registration. Your activation email should arrive soon. *Note: if you can\'t find activation email in your inbox, check your spam folder.</p>
				<p><a href="index.php">Click here</a> for login if you activated your account.</p>
				</div>
				
				</body>
				</html>
				';	
				
	} else {
	
		echo '
				<html>
				<head>
				<title>Error</title>
				</head>
				
				<body>
				
				<div>
				<p>Accept our apologies, we have encountered some problems.</p>
				<p>Your data is not lost, no need to worry. User: '.$username.' | Pass: '.$pass.' | E-mail: '.$email.' | Name: '.$name.'</p>
				<p>Try again later.</p>
				</div>
				
				</body>
				</html>
				';	
				
	}
				
} else {
?>

<div id="error"><p>WELCOME to registration. Please, enter all fields below. </div><br>
    <strong>You need to fill all fields below!  </strong></p>
  <form action="<?= $_SERVER['PHP_SELF'] ?>" method="post">
	  <table width="60%"  border="0" align="center" cellpadding="0" cellspacing="0">
		<tr class="firstRow">
		  <td width="35%"><div align="right">Name:</div></td>
		  <td width="65%">&nbsp;<input name="firstname" type="text" class="textBox" id="firstname"></td>
		</tr>
		<tr class="firstRow">
		  <td><div align="right">Email adress:</div></td>
		  <td>&nbsp;<input name="email" type="text" class="textBox" id="email"></td>
		</tr>
		<tr class="secondRow">
		  <td><div align="right">Username:</div></td>
		  <td>&nbsp;<input name="username" type="text" class="textBox" id="username"></td>
	    </tr>
		<tr class="firstRow">
		  <td><div align="right">Password:</div></td>
		  <td>&nbsp;<input name="password" type="password" class="textBox" id="password"></td>
		</tr>
		<tr class="secondRow">
		  <td><div align="right">Confirm password: </div></td>
		  <td>&nbsp;<input name="confirm" type="password" class="textBox" id="confirm"></td>
		</tr>
		<tr class="firstRow">
		  <td colspan="2"><div align="center">
		    <p>&nbsp;		      </p>
		    <p>
		      <input name="submit" type="submit" class="textBox" value="Register account">
		      </p>
		  </div></td>
		  </tr>
	  </table>
  </form>
  <br />
  *After you succesfully register your account, an email will be sent to your inbox containing your registration details and instructions on how to activate your account. 
  </div>

  </div>

<? 
}
?>
		 
		</TD>
		<TD valign='top' align='left' id='body-right'>

		<br />
		</td>
	</TR>
	<tr>
	<td colspan='2' align='right' id='foot'>copyright by Nosf // 2008 | core engine by <a href='http://www.bbgdev.com/' target='_blank'>Dominant Creature</a></td>
	</tr>
</TABLE>
<!-- End ImageReady Slices -->
</BODY>
</HTML>
Return current item: Dominant Creature RPG