Existe una tabla, Characters > Rebirth
y cada rebirth se agrega una suma de 1 por cada rebirth que se hace.
Quisiera hacer que este, imponga una condicion, que cuando vea que este supere el numero 3 de rebirths, ponga un error sobre que no se puede hacer más.
Lo siento pero he estado explorando esto un rato grande y me salta muchos errores, y es que aun no soy tan experto en PHP.
Código PHP:
<!-- Main Content Start -->
<div id="primarycontent">
<!-- Primary Content Start -->
<div class="post">
<div class="header">
<h3>RockMS Rebirth Web!</h3>
</div>
<div class="content">
<p><font size=+1><b>D</b></font>id you reach <strong><u><font color=blue>Level 200</font></u></strong> Fill out this form and reborn your character! You'll get a fresh start as a <strong><u><font color=blue>Lv01 Beginner</font></u></strong></p>
</div>
<?php
// process the script only if the form has been submitted
if (array_key_exists('reset', $_POST)) {
include('config2.php');
// start the session
$username = trim($_POST['username']);
$password = trim($_POST['password']);
$character = trim($_POST['character']);
$level = trim($_POST['level']);
$idchar = trim($_POST['id']);
$username = mysql_real_escape_string($username);
$result = mysql_query("SELECT level FROM characters WHERE name = '$character'");
list($level) = mysql_fetch_row($result);
$result = mysql_query("SELECT id FROM characters WHERE name = '$character'");
list($idchar) = mysql_fetch_row($result);
$sql = "SELECT * FROM accounts WHERE name = '$username'";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
if (hash('sha512', $password.$row['salt']) == $row['password'] && $level >=200) {
mysql_query("UPDATE characters SET ap = 9 WHERE name='$character'");
mysql_query("UPDATE characters SET level = 1 WHERE name='$character'");
mysql_query("UPDATE characters SET job = 0 WHERE name='$character'");
mysql_query("UPDATE characters SET `int` = 4 WHERE name='$character'");
mysql_query("UPDATE characters SET str = 4 WHERE name='$character'");
mysql_query("UPDATE characters SET dex = 4 WHERE name='$character'");
mysql_query("UPDATE characters SET luk = 4 WHERE name='$character'");
mysql_query("UPDATE characters SET exp = 0 WHERE name='$character'");
mysql_query("UPDATE characters SET hp = 50 WHERE name='$character'");
mysql_query("UPDATE characters SET maxhp = 50 WHERE name='$character'");
mysql_query("UPDATE characters SET mp = 50 WHERE name='$character'");
mysql_query("UPDATE characters SET maxmp = 50 WHERE name='$character'");
mysql_query("UPDATE characters SET sp = 0 WHERE name='$character'");
mysql_query("UPDATE characters SET rebirth = rebirth + 1 WHERE name='$character'");
mysql_query("DELETE FROM skills WHERE characterid=$idchar");
$result = mysql_query or die(mysql_error());
if ($result) {
$message[] = "$character has been Reborn!<br />
Go <strong><u>play</u></strong> and <strong><u>own</u></strong>!";
}
}
else {
$message[] = "There was a problem reborning $character. Please make sure you entered all the fields correctly and you are level 200 or above.";
}
}
?>
<!-- start content -->
<link rel="stylesheet" href="style2.css" type="text/css">
<div class='welcome'><strong>Character Rebirth</strong></div>
<div align="center">
<div class="display">
<?php
if (isset($message)) {
echo '<ul>';
foreach ($message as $item) {
echo "<li>$item</li>";
}
echo '</ul>';
}
?>
</div>
<form id="form1" name="form1" method="post" action="">
<table cellspacing="0" cellpadding="5" width="100%">
<tr>
<td width="20%" align="left" class="list">Account Name :</td>
<td class="list"><input id="username" type="text" name="username" maxlength="12"></td>
</tr>
<tr>
<td width="20%" align="left" class="list">Password :</td>
<td class="list"><input id="password" type="password" name="password" maxlength="20" /></td>
</tr>
<tr>
<td width="20%" align="left" class="list">Character :</td>
<td class="list"><input id="character" type="character" name="character" maxlength="20" /></td>
</tr>
<tr>
<td align="left" colspan="2"><input id="reset" name="reset" type="submit" value="Reborn NOW!" /></td>
</tr>
</table>
</form>
</div>
<!-- end content -->
</div>
<!-- Primary Content End -->
<!-- Main Content End -->