This a script I am making that checks if logged in, if so redirects, if not created a profile page and redirects to TOS. I have a working code using a basic INSERT that works (On Top). Then one that I cannot get to work using prepared statements below.
<?php
session_start();
require ('../../../mysql_connect/mysqli_connect_accounts.php');
require ('../steamauth/steamauth.php');
require ('../steamauth/userInfo.php');
$steamid=$_SESSION['steamid'];
$query = "SELECT * FROM `".$steamid."`";
$response = @mysqli_query($dbc, $query);
if($response){
header("Location: http://theskindealer.com/index.php");
} else {
$create = "CREATE TABLE `".$steamid."` (
steamid VARCHAR(30),
fullname VARCHAR(30),
tradeurl VARCHAR(30),
email VARCHAR(50),
age INT(3),
tos INT(1),
access INT(1),
first INT(1),
balance DECIMAL(9,2)
)";
if ($dbc->query($create) === TRUE) {
$insert = "INSERT INTO `".$steamid."` (steamid, first, access, tos, balance, age, email, tradeurl, fullname) VALUES ($steamid, 1, 0, 0, 0.00, 0, 0, 0, 0)";
if ($dbc->query($insert) === TRUE) {
header("Location: http://theskindealer.com/tos/accept.php");
} else {
header("Location: http://theskindealer.com/pages/errorlogin.php");
}
} else {
header("Location: http://theskindealer.com/pages/errorlogin.php");
}
}
$dbc->close();
mysqli_close($dbc);
?>
Then... this code either redirects to index all the time even after wiping db, and doesn't save data. Or white screens and doesn't save data.
<?php
session_start();
require ('../../../mysql_connect/mysqli_connect_accounts.php');
require ('../steamauth/steamauth.php');
require ('../steamauth/userInfo.php');
$steamid=$_SESSION['steamid'];
$query = "SELECT * FROM `".$steamid."`";
$response = @mysqli_query($dbc, $query);
if($response){
header("Location: http://theskindealer.com/index.php");
} else {
$create = "CREATE TABLE `".$steamid."` (
steamid VARCHAR(30),
fullname VARCHAR(30),
tradeurl VARCHAR(30),
email VARCHAR(50),
age INT(3),
tos INT(1),
access INT(1),
freeze INT(1),
balance DECIMAL(9,2)
)";
if ($dbc->query($create) === TRUE) {
$insert = "INSERT INTO `".$steamid."` (steamid, freeze, access, tos, balance, age, email, tradeurl, fullname) VALUES (:steamid, :freeze, :access, :tos, :balance, :age, :email, :tradeurl, :fullname)";
$stmt = $dbc->prepare($insert);
$stmt->bind_param(':steamid', $steam64);
$stmt->bind_param(':freeze', $freeze);
$stmt->bind_param(':access', $access);
$stmt->bind_param(':tos', $tos);
$stmt->bind_param(':balance', $balance);
$stmt->bind_param(':age', $age);
$stmt->bind_param(':email', $email);
$stmt->bind_param(':tradeurl', $tradeurl);
$stmt->bind_param(':fullname', $fullname);
$steam64 = $steamid;
$freeze = 0;
$access = 0;
$tos = 0;
$balance = 0.00;
$age = 0;
$email = "null";
$tradeurl = "null";
$fullname = "null";
$stmt->execute();
header("Location: http://theskindealer.com/tos/accept.php");
} else {
header("Location: http://theskindealer.com/pages/errorlogin.php");
}
}
$stmt->close();
$dbc->close();
mysqli_close($dbc);
?>