Имам онлайн игра и е направена слет като се регистрираш да се потварждава регистрацията от имейла
Въпроса ми е как мога да го махна слет като се регистрират направо да могат да влизат :idea:
Ето файловете
register.php
validate2.php
validate.php
verify.php
Който ми помогне получава незабавно точка 8)
Въпроса ми е как мога да го махна слет като се регистрират направо да могат да влизат :idea:
Ето файловете
register.php
Код:
<? session_start(); ?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251"> </head>
<?php
include( "includes/inc-header.php" );
echo "<br>";
if ( !$_GET['stp'] ) {
?>
<form action="register.php?stp=2" method="post">
<table width="60%" border="0" align="center">
<tr>
<td colspan="4" class="bodycell3">Регистрация</td>
</tr>
<tr>
<td class="bodycell4" width="50%" align="right">
<b>Име на акаунта:</b>
</td>
<td class="bodycell4" width="50%">
<input name="username" type="text" size="30">
</td>
</tr>
<tr>
<td class="bodycell4" colspan="2" align="center">
Your username may be between 5 - 16 Characters.
</td>
</tr>
<tr>
<td class="bodycell4" width="50%" align="right">
<b>Парола:</b>
</td>
<td class="bodycell4" width="50%">
<input name="password1" type="password" size="30">
</td>
</tr>
<tr>
<td class="bodycell4" width="50%" align="right">
<b>Отново паролата:</b>
</td>
<td class="bodycell4" width="50%">
<input name="password2" type="password" size="30">
</td>
</tr>
<tr>
<td class="bodycell4" colspan="2" align="center">
Your password may be between 5 - 10 Characters.
</td>
</tr>
<tr>
<td class="bodycell4" width="50%" align="right">
<b>Поща:</b>
</td>
<td class="bodycell4" width="50%">
<input name="email1" type="text" size="30">
</td>
</tr>
<tr>
<td class="bodycell4" width="50%" align="right">
<b>Отново поща:</b>
</td>
<td class="bodycell4" width="50%">
<input name="email2" type="text" size="30">
</td>
</tr>
<tr>
<td class="bodycell4" colspan="2" align="center">
Email must be correct as you need to validate your account.
</td>
</tr>
<tr>
<td class="bodycell4" width="50%" align="right">
<b>Първо име :</b>
</td>
<td class="bodycell4" width="50%">
<input name="firstname" type="text" size="30">
</td>
</tr>
<tr>
<td class="bodycell4" width="50%" align="right">
<b>Второ име :</b>
</td>
<td class="bodycell4" width="50%">
<input name="lastname" type="text" size="30">
</td>
</tr>
<tr>
<td class="bodycell4" width="50%" align="right">
<b>Род:</b>
</td>
<td class="bodycell4" width="50%">
<select name="gender">
<option value="Male">Мъж</option>
<option value="Female">Жена</option>
</select>
</td>
</tr>
<tr>
<td class="bodycell4" width="50%" align="right">
<b>Раса:</b>
</td>
<td class="bodycell4" width="50%">
<select name="race">
<option value="1"><?=$SETTINGS['prace_1']?></option>
<option value="2"><?=$SETTINGS['prace_2']?></option>
<option value="3"><?=$SETTINGS['prace_3']?></option>
<option value="4"><?=$SETTINGS['prace_4']?></option>
<option value="5"><?=$SETTINGS['prace_5']?></option>
<option value="6"><?=$SETTINGS['prace_6']?></option>
</select>
</td>
</tr>
<tr>
<td class="bodycell4" colspan="2">
Races start with:<br>
-><?=$SETTINGS['prace_1']?>: +2500 Defense, +2500 Offense, +15000 Gold<br>
-><?=$SETTINGS['prace_2']?>: +5 Army, +40000 Gold<br>
-><?=$SETTINGS['prace_3']?>: +5000 Offense, +2500 Defense<br>
-><?=$SETTINGS['prace_4']?>: +7500 Defense<br>
-><?=$SETTINGS['prace_5']?>: +7500 Offense<br>
-><?=$SETTINGS['prace_6']?>: +5000 Offense, +25000 Gold<br>
</td>
</tr>
<tr>
<td colspan="4" class="bodycell4">
<center>
<input name="register" type="submit" value="Register">
</center>
</td>
</tr>
</table>
</form>
<?php
} elseif ( $_GET['stp'] == 2 ) {
$username = htmlentities( stripslashes( $_POST['username'] ) );
$password1 = stripslashes( $_POST['password1'] );
$password2 = stripslashes( $_POST['password2'] );
$email1 = strip_tags( stripslashes( $_POST['email1'] ) );
$email2 = strip_tags( stripslashes( $_POST['email2'] ) );
$firstname = htmlentities( stripslashes( $_POST['firstname'] ) );
$lastname = htmlentities( stripslashes( $_POST['lastname'] ) );
$gender = htmlentities( stripslashes( $_POST['gender'] ) );
$race = htmlentities( stripslashes( $_POST['race'] ) );
$utaken = $db->fetch( $db->query( "SELECT * FROM users WHERE uLogin=\"$username\"" ) );
$etaken = $db->fetch( $db->query( "SELECT * FROM users WHERE uEmail=\"$email1\"" ) );
echo "<center>";
if ( strlen( $username ) < 5 ) {
echo "Your username is too short.";
} elseif ( strlen( $username ) > 16 ) {
echo "Your username is too long.";
} elseif ( $utaken ) {
echo "The username you entered is already in use.";
} elseif ( $password1 != $password2 ) {
echo "The passwords entered do not match.";
} elseif ( strlen( $password1 ) < 5 ) {
echo "Your password is too short.";
} elseif ( strlen( $password1 ) > 10 ) {
echo "Your password is too long.";
} elseif ( $email1 != $email2 ) {
echo "The emails entered do not match.";
} elseif ( $etaken ) {
echo "The email you entered is already in use.";
} else {
if ( !$firstname ) {
$firstname = "n/a";
}
if ( !$lastname ) {
$lastname = "n/a";
}
if ( $race == 1 ) {
$citizens = "3";
$gold = "40000";
$offense = "7500";
$defense = "7500";
} elseif ( $race == 2 ) {
$citizens = "8";
$gold = "65000";
$offense = "5000";
$defense = "5000";
} elseif ( $race == 3 ) {
$citizens = "3";
$gold = "25000";
$offense = "10000";
$defense = "7500";
} elseif ( $race == 4 ) {
$citizens = "3";
$gold = "25000";
$offense = "5000";
$defense = "12500";
} elseif ( $race == 5 ) {
$citizens = "3";
$gold = "25000";
$offense = "12500";
$defense = "5000";
} elseif ( $race == 6 ) {
$citizens = "3";
$gold = "50000";
$offense = "10000";
$defense = "5000";
}
$randcode = rand( 1000, 9999 ) . "-" . rand( 1000, 9999 ) . "-" . rand( 100, 999 );
if ( $_SESSION['refid'] ) {
$db->query( "INSERT INTO referal_list (`uReferer`,`uReferee`) VALUES ('" . $_SESSION['refid'] . "','$theid')" );
}
$query = "INSERT INTO `users` ";
$query .= "( `uEmail` , `uLogin` , `uPassword` , `uFirstName` , `uLastName` , `uGender` , `uCode` , `uRace` , `uGold` , `uCitizens` , `uOffensiveMen` , `uDefensiveMen` , `uMiners` , `uOffense` , `uDefense` ) ";
$query .= "VALUES (\"$email1\", \"$username\", \"$password1\", \"$firstname\", \"$lastname\", \"$gender\", \"$randcode\", \"$race\", \"$gold\", \"$citizens\", \"5\", \"5\", \"1\", \"$offense\", \"$defense\")";
$db->query( $query );
$linsrt = mysql_insert_id();
$db->query( "INSERT INTO users_online (`uID`,`uIPAddress`,`uCode`) VALUES (\"$linsrt\",\"" . $REMOTE_ADDR . "\",\"logged_out\")" );
$x = 1;
$YourRegLink = $SETTINGS['game_url'] . "validate2.php?email=" . $email1 . "&code=" . $randcode;
$TheSender = $SETTINGS['game_email'];
$TheRecipient = $email1;
$TheSubject = $SETTINGS['gamename'] . ": Validation Code";
$TheText = "<font face='Tahoma' size='1'>Dear " . $username . ",<br>Welcome to " . $SETTINGS['gamename'] . ". <BR> You will need to type in the following confirmation code on the website, before you can play " . $SETTINGS['gamename'] . ".<br> <br> REG-CODE: " . $randcode . "<br> <br> Or you can click the following link:<br> <a href='" . $YourRegLink . "'>" . $YourRegLink . "</a><BR><BR>";
$TheText = $TheText . "Or, you could copy and paste the following url into your browser:<BR>" . $YourRegLink . "</font>";
$TheText = $TheText . "<BR><BR>";
$TheText = $TheText . "Any replies to this email will be automatically deleted.";
$TheText2 = "Dear " . $username . ",\r\nWelcome to " . $SETTINGS['gamename'] . ". \r\n You will need to type in the following confirmation code on the website, before you can play " . $SETTINGS['gamename'] . ".\r\n\r\n REG-CODE: " . $randcode . "\r\n \r\n";
$TheText2 = $TheText . "Or, you could copy and paste the following url into your browser:\r\n" . $YourRegLink;
$TheText2 = $TheText . "\r\n\r\n";
$TheText2 = $TheText . "Any replies to this email will be automatically deleted.";
$headers = "From: $TheSender\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$boundary = uniqid( "hbsignup" );
$headers .= "Content-Type: multipart/alternative" . "; boundary = $boundary\r\n\r\n";
$headers .= "$TheText2\r\n\r\n";
$headers .= "--$boundary\r\n" . "Content-Type: text/plain; charset=ISO-8859-1\r\n" . "Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split( base64_encode( $TheText2 ) );
$headers .= "--$boundary\r\n" . "Content-Type: text/html; charset=ISO-8859-1\r\n" . "Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split( base64_encode( $TheText ) );
if ( mail( $email1, $TheSubject, "", $headers ) ) {
?>
Вашия утвърждаване код е бил изпратен.<BR>
Веднъж вие сте получили вашия код, <A HREF='validate.php'>кликнете тук </A> за да активирате своя акаунт
<?php
} else {
?>
Вия имате да <h5><A HREF="validate2.php?email=<?php echo $email1;
?>&code=<?php echo $randcode;
?>"><B>Активирай</B></A></h5> вашия акаунт, преди вие можете да играете.<BR>
Моля активизира вашия акаунт, от <A HREF="validate2.php?email=<?php echo $email1;
?>&code=<?php echo $randcode;
?>"><B>Кликни тука!</B></A>.<BR>
От тук можете да влезнете!
<BR>
<?php
}
}
if ( !$x ) {
echo "<br><br>";
echo "<a href=\"javascript:history.back();\">BACK</a>";
}
echo "</center>";
}
include( "includes/inc-footer.php" );
?>
validate2.php
Код:
<?php
include( "includes/inc-header.php" );
$email = htmlentities( stripslashes( $_GET['email'] ) );
$code = htmlentities( stripslashes( $_GET['code'] ) );
$code = rtrim( $code );
$code = ltrim( $code );
if ( !$email ) {
$email = addslashes( $_POST['email'] );
$code = htmlentities( stripslashes( $_POST['code'] ) );
}
$query = "SELECT * FROM users WHERE uEmail=\"$email\"";
$result = $db->query( $query );
$row = $db->fetch( $result );
echo "<br><center>";
if ( !$row ) {
echo "The email you entered was not found in our database. Please <A HREF='register.php'>Create an Account</a>.";
} elseif ( $row['uCode'] == "done" ) {
echo "You account has already been activated.";
} elseif ( $row['uCode'] != $code ) {
echo "The confirmation code you entered is invalid. Please <A HREF='validate.php'>go back</a> and enter it correctly.";
} elseif ( $row['uCode'] == $code ) {
$query = "UPDATE users SET uCode='done' WHERE uEmail='$email'";
$result = $db->query( $query );
echo "Congratulations, your account has been activated. Please <A HREF='index.php'>Login</a>, and start playing.";
}
echo "<br></center>";
include( "includes/inc-footer.php" );
?>
validate.php
Код:
<? session_start(); ?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251"> </head>
<?php
include( "includes/inc-header.php" );
?>
<br>
<form method="POST" action="validate2.php">
<table border="0" align="center">
<tr>
<td>Поща:</td>
<td><input type="text" name="email" size="20"></td>
</tr>
<tr>
<td>Код:</td>
<td><input type="text" name="code" size="20"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Enter Code" name="Submit"></td>
</tr>
</table>
</form>
<?php
include( "includes/inc-footer.php" );
?>
verify.php
Код:
<?php
include( "includes/inc-setup.php" );
session_start();
$_POST['username'] = htmlentities( $_POST['username'] );
$row = $db->fetch( $db->query( "SELECT uID,uPassword,uCode FROM users WHERE uLogin=\"" . $_POST['username'] . "\"" ) );
if ( $_POST['password'] == $row['uPassword'] && $row['uCode'] == "done" ) {
$sessionid = "l-in" . rand( 100, 999 ) . substr( $_POST['username'], 0, 3 ) . rand( 100000, 999999 );
$_SESSION['ht_mem'] = $sessionid;
$db->query( "UPDATE users_online SET uCode=\"$sessionid\" WHERE uID=$row[uID]" );
header( "Location: play/index.php" );
} else {
$_SESSION['ht_mem'] = "";
if ( !$row ) {
$cd = 3;
}
if ( $row[uCode] != "done" ) {
$cd = 2;
} else {
$cd = 1;
}
header( "Location: login.php?err=$cd" );
}
$db->close();
?>
Който ми помогне получава незабавно точка 8)