crie um arquivo chamado config.php.
Em 'aquisuasenha' você coloca a senha do root.
$gd=999999; e a quantidade de T-pont que o player vai ganhar.
Agora crie um outro arquivo chamado register-exec.php
Agora um outro arquivo register-form.php
Crie ultimo arquivo chamado register-success.php
Em 'aquisuasenha' você coloca a senha do root.
$gd=999999; e a quantidade de T-pont que o player vai ganhar.
- Código:
<?php
define('DB_HOST', '127.0.0.1');
define('DB_USER', 'root');
define('DB_PASSWORD', 'aquisuasenha');
define('DB_DATABASE', 'db_account');
$gd=999999;
?>
Agora crie um outro arquivo chamado register-exec.php
- Código:
<?php
//Start session
session_start();
//Include database connection details
require_once('config.php');
//Array to store validation errors
$errmsg_arr = array();
//Validation error flag
$errflag = false;
//Connect to mysql server
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
//Select database
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
die("Unable to select database");
}
//Function to sanitize values received from the form. Prevents SQL injection
function clean($str) {
$str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}
//Sanitize the POST values
$login = clean($_POST['login']);
$password = clean($_POST['password']);
$cpassword = clean($_POST['cpassword']);
$email = clean($_POST['email']);
$city = clean($_POST['city']);
//Input Validations
if($login == '') {
$errmsg_arr[] = 'Login ID missing';
$errflag = true;
}
if($password == '') {
$errmsg_arr[] = 'Password missing';
$errflag = true;
}
if($cpassword == '') {
$errmsg_arr[] = 'Confirm password missing';
$errflag = true;
}
if( strcmp($password, $cpassword) != 0 ) {
$errmsg_arr[] = 'Passwords do not match';
$errflag = true;
}
if($email == '') {
$errmsg_arr[] = 'Email missing';
$errflag = true;
}
if($email == '') {
$errmsg_arr[] = 'City missing';
$errflag = true;
}
//Check for duplicate login ID
if($login != '') {
$qry = "SELECT * FROM t_account WHERE name='$login'";
$result = mysql_query($qry);
if($result) {
if(mysql_num_rows($result) > 0) {
$errmsg_arr[] = 'Login ID already in use';
$errflag = true;
}
@mysql_free_result($result);
}
else {
die("Query Failed");
}
}
//If there are input validations, redirect back to the registration form
if($errflag) {
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
session_write_close();
header("location: register-form.php");
exit();
}
//Create INSERT query
$qry = "INSERT INTO t_account (name, pwd, pw2, gd, email, city) VALUES('$login','".md5($_POST['password'])."','$password','$gd','$email','$city')";
$result = @mysql_query($qry);
//Check whether the query was successful or not
if($result) {
header("location: register-success.php");
exit();
}else {
die("Query Failed");
}
?>
Agora um outro arquivo register-form.php
- Código:
<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Talisman Felspire</title>
</head>
<body oncontextmenu='return false' onselectstart='return false' ondragstart='return false' bgcolor="#000000">
<center><?php
if( isset($_SESSION['ERRMSG_ARR']) && is_array($_SESSION['ERRMSG_ARR']) && count($_SESSION['ERRMSG_ARR']) >0 ) {
echo '<ul class="err">';
foreach($_SESSION['ERRMSG_ARR'] as $msg) {
echo '<li>',$msg,'</li>';
}
echo '</ul>';
unset($_SESSION['ERRMSG_ARR']);
}
?></center>
<tr>
<td height="1000" valign="top" style="font-size:14px; text-align: center;"><p> </p>
<center><form id="loginForm" name="loginForm" method="post" action="register-exec.php">
<tr>
<th width="124"><div align="center"><span class="style7"> <font color="#FFFFFF">User ID</font></span></div></th>
<td width="120" bgcolor=""><input name="login" type="text" class="textfield" id="login" /></td>
</tr>
<tr>
<th><div align="center"><span class="style3"><font color="#FFFFFF">Password</font></span></div></th>
<td bgcolor=""><input name="password" type="password" class="textfield" id="password" /></td>
</tr>
<tr>
<th><div align="center"><span class="style3"><font color="#FFFFFF">Confirm Pass</font></span></div></th>
<td bgcolor=""><input name="cpassword" type="password" class="textfield" id="cpassword" /></td>
</tr>
<tr>
<th><div align="center"><span class="style3"><font color="#FFFFFF">ADD E-mail</font></span></div></th>
<td bgcolor=""><input name="email" type="text" class="textfield" id="email" /></td>
</tr>
<tr>
<th><div align="center"><span class="style3"><font color="#FFFFFF">City</font></span></div></th>
<td bgcolor=""><input name="city" type="text" class="textfield" id="city" /></td>
</tr>
<tr>
<th><div align="center"><input type="submit" name="Submit" value="Register" /></div></td>
</tr>
</table>
</form>
</body>
</html>
Crie ultimo arquivo chamado register-success.php
- Código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Talisman Felspire</title>
<style type="text/css">
body {
background-color: #000;
}
#update {
font-size: xx-large;
color: #ffffff;
text-align: center;
}
</style>
</head>
<body oncontextmenu='return false' onselectstart='return false' ondragstart='return false' bgcolor="#000000">
<div id="update">
<p>Registration Completed</p>
</div>
</body>
</html>