I am actually not able to get this to work.
PHP Code:
<?php
if(!isset($_POST['Submit'])){
?>
<form id="form1" name="form1" method="post" action="reg.php">
<table width="500" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="174" align="right" valign="top"><div align="right">Username: </div></td>
<td width="326" align="left" valign="top"><input name="username" type="text" class="formelements" id="username" size="40" maxlength="9" />
<br />
<span class="style1">*must be 9 characters or less</span> </td>
</tr>
<tr>
<td align="right" valign="top"><div align="right">Password: </div></td>
<td align="left" valign="top"><input name="password" type="password" class="formelements" id="password" size="40" maxlength="9" />
<br />
<span class="style1">*must be 9 characters or less</span></td>
</tr>
<tr>
<td colspan="2" align="center" valign="top"><input name="Submit" type="submit" class="formelements" value="Login/Create" /> <input name="Reset" type="reset" class="formelements" value="Clear" /></td>
</tr>
</table>
</form>
<?php
} else {
//set font color
$link = mysql_connect($DB_ADDY,$DB_USER,$DB_PASS);
mysql_select_db($DB_DB,$link);
$sql = "SELECT * FROM `account` WHERE `name` = '". $_POST['username']. "'";
$res = mysql_query($sql,$link);
if(mysql_num_rows($res) != 0){
//username was found
$info = mysql_fetch_assoc($res);
if($info['password'] == $_POST['password']){
//password matches
if($_SERVER['REMOTE_ADDR'] != $info['minilogin_ip']){
//ip address has changed
$sql = "UPDATE `account` SET `minilogin_ip` = '". $_SERVER['REMOTE_ADDR']. "' WHERE `name` = '". $_POST['username']. "' AND `password` = '". $_POST['password']. "'";
$sql2 = "UPDATE `account` SET `minilogin_ip` = '0.0.0.0' WHERE `minilogin_ip` = '". $_SERVER['REMOTE_ADDR']. "'";
if(($res = mysql_query($sql2,$link)) && mysql_query($sql,$link)){
echo '<font color="#00FF00">';
echo 'Your IP address was successfully updated. You may now start EverQuest Titanium Edition and log in to the server.';
echo '</font>';
} else {
echo '<font color="#FF0000">';
echo 'There was an error updating your IP address. Please try again later or contact an admin for assistance.';
echo '</font>';
}
} else {
//ip didnt change
echo '<font color="#00FF00">';
echo 'Your IP address has not changed. You may now start EverQuest Titanium Edition and log in to the server.';
echo '</font>';
}
} else {
//password was wrong
echo '<font color="#FF0000">';
echo 'The username: '. $_POST['username']. '<br />Already exists in our database, and the password<br />you entered for it was incorrect.<br />';
echo 'If this is your account, please <a href="index.php">go back</a>, re-enter your password, and try again.<br />';
echo 'If you were attempting to create a new account, please try a different user name.';
echo '</font>';
}
} else {
//username was not found create it now
$newno = "SELECT `id` FROM `account` ORDER BY `id` DESC LIMIT 1";
$res = mysql_query($newno,$link);
$newno = mysql_fetch_assoc($res);
$newno = ($newno['id'] + 1);
$sql = "INSERT INTO `account` VALUES (". $newno. ",'". $_POST['username']. "','',0,'". $_POST['password']. "',". $admin_level. ",". $newno. ",0,0,'". $_SERVER['REMOTE_ADDR']. "',0,0)";
$sql2 = "UPDATE `account` SET `minilogin_ip` = '0.0.0.0' WHERE `minilogin_ip` = '". $_SERVER['REMOTE_ADDR']. "'";
if(($res = mysql_query($sql2,$link)) && mysql_query($sql,$link)){
echo '<font color="#00FF00">';
echo 'New account created successfully. You may now start EverQuest Titanium Edition and log in to the server using:<br />';
echo 'Username: '. $_POST['username']. '<br />Password: '. $_POST['password']. '<br />*username and password are case sensitive!';
echo '</font>';
} else {
echo '<font color="#FF0000">';
echo 'There was an error while trying to create your account. Please try again later.';
echo '</font>';
}
}
}
?>
No matter what I do it always redirects to the red *error has occured while trying to create account*
Database info is correct on it..