Quote
I am not sure why this is erroring out after staring at it and trying to make adjustments for awhile to it.
I'm using:
PHP 5
MySQL
Here is the page code [long]:
<?php
include("smarty_include.php");
include ('db_var.php');
if ($_POST) {
$user=$_POST['user_name'];
$password=$_POST['password'];
$email=$_POST['email'];
$faction=$_POST['faction'];
$confirmed=0;
$admin=0;
$beta_tester=0;
$wins=0;
$losses=0;
$points=0;
$rank = "Ensign";
$confirm=$_POST['confirmpw'];
$ship_name=$_POST['vessel_name'];
$class="Cadet Cruiser";
$country="Not Stated";
$points=0;
$wins=0;
$losses=0;
$point_value=50;
$pos_x=rand(0,1000);
$pos_y=rand(0,1000);
$shield=2;
$max_shield=2;
$heavy_weapon=2;
$max_heavy_weapon=2;
$main_phaser=2;
$max_main_phaser=2;
$secondary_phaser=2;
$max_secondary_phaser=2;
$defensive_phaser=2;
$max_defensive_phaser=2;
$hull=2;
$max_hull=2;
$lab=2;
$max_lab=2;
$trans=2;
$max_trans=2;
$bridge=2;
$max_bridge=2;
$sl_engine=2;
$max_sli_engine=2;
$aux_power=2;
$max_aux_power=2;
$battery=2;
$max_battery=2;
$small_craft=2;
$max_small_craft=2;
$extra_damage=2;
$max_extra_damage=2;
$w_engine=2;
$max_w_engine=2;
if ($password != $confirm)
{
print("<span style='color:red'>ERROR: Passwords do not match! </span>");
}
$mysqli = new mysqli($host, $dbuser, $pw, $db);
if ( $mysqli->errno)
{
printf("Unable to connect to the database: <br /> %s", $mysqli->error);
exit();
}
$query="SELECT * FROM `users` WHERE `user_name` = '$user' ";
$result=$mysqli->query($query);
if (!$result) {
printf("Invalid query: %s", $mysqli->error);
exit();
}
if ($result->num_rows > 0)
{
printf("Sorry but character name %s is already taken.", $user);
exit();
}
;
$query=" SELECT * FROM ships WHERE `ship_name` = '$vessel_name'";
$result=$mysqli->query($query, MYSQLI_STORE_RESULT);
if (!$result) {
printf("Invalid query: %s", $mysqli->error);
exit();
}
if ($result->num_rows > 0)
{
printf("Sorry but vessel name %s is already taken.", $vessel_name);
exit();
}
$query=" SELECT * FROM users WHERE `email` = '$email'";
$result=$mysqli->query($query, MYSQLI_STORE_RESULT);
if (!$result) {
printf("Invalid query: %s", $mysqli->error);
exit();
}
if ($result->num_rows > 0)
{
printf("Sorry but a player is already using %s as an email address.", $email);
exit();
}
$query="INSERT INTO 'users' ('user_name','password','email','faction','confirmed','admin','beta_tester','wins','losses','points','rank') VALUES ('$user',(md5('$password')),'$email','$faction','$confirmed','$admin','$beta_tester','$wins','$losses','$points','$rank',);";
$result=$mysqli->query($query);
if (!$result) {
printf("Invalid query: %s", $mysqli->error);
exit();
}
$query = "UPDATE users SET date_joined = NOW() WHERE 'user_name' = '$user'";
$result=$mysqli->query($query);
if (!$result) {
printf("Invalid query: %s", $mysqli->error);
exit();
}
$query = "UPDATE users SET date_lastlogin = NOW() WHERE 'user_name' = '$user'";
$result=$mysqli->query($query);
if (!$result) {
printf("Invalid query: %s", $mysqli->error);
exit();
}
$query="INSERT INTO ships ( 'user_name', 'ship_type','ship_name','faction','pos_x','pos_y','class','points','shield','heavy_weapon','main_phaser','secondary_phaser','defensive_phaser','hull','lab','trans','bridge','sl_engine','aux_power','battery','small_craft','extra_damage','w_engine','crew','marines','sensors','max_shield','max_heavy_weapon','max_main_phaser','max_secondary_phaser','max_defensive_phaser','max_hull','max_lab','max_trans','max_bridge','max_sl_engine','max_aux_power','max_battery','max_small_craft','max_extra_damage','max_w_engine','max_crew','max_marines','max_sensors') VALUES ('$user_name','$class','$ship_name','$faction','$pos_x','$pos_y','$class','$points','$shield','$heavy_weapon','$main_phaser','$secondary_phaser','$defensive_phaser','$hull','$lab','$trans','$bridge','$sl_engine','$aux_power','$battery','$small_craft','$extra_damage','$w_engine','$crew','$marines','$sensors','$max_shield','$max_heavy_weapon','$max_main_phaser','$max_secondary_phaser','$max_defensive_phaser','$max_hull','$max_lab','$max_trans','$max_bridge','$max_sl_engine','$max_aux_power','$max_battery','$max_small_craft','$max_extra_damage','$max_w_engine','$max_crew','$max_marines','$max_sensors',);";
$result=$mysqli->query($query);
if (!$result) {
printf("Invalid query: %s", $mysqli->error);
exit();
}
$to = $email;
$subject = 'Sector Battles e-mail confirmation';
$message = "
<p>Hey! Thanks for signing up for Sector Battles. Click below to confirm your e-mail address.</p>
<p><a href='http://sectorbattles.com/confirm.php?email=$email'>By Clicking Here</a></p>";
$headers = 'From: fleetregistration@sectorbattles.com' . "\r\n" .
'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to,$subject,$message,$headers);
}
$smarty->display('register.tpl');
?>
The includes at the top are just the smarty template paths and my db log in information
Anyone see something here?

New Topic/Question
Reply




MultiQuote






|