Need Help: PHP Not redirecting 08-28-2017, 04:01 AM
#1
I was using mysqli in the past and i decided to go and switch everything to PDO on this go around and im having a problem with my header("Location: profile.php"); not redirecting.
root/include/dbc.php
root/profile.php
my dbc.php is included into my index.php file where the forms are located any help would be appreciated .. thanks
root/include/dbc.php
Code:
<?
session_start();
# Connect to the Database:
try {
$host = ''; // Host name
$name = ''; // Database name
$user = ''; // Username
$pass = ''; // Password
$dbc = new PDO("mysql:host=$host;dbname=$name", $user, $pass);
}
catch(PDOException $e) {
echo $e->getMessage();
}
###### Register USER ######
if(isset($_POST['register'])){
$stmt = $dbc->prepare("INSERT INTO users ( gamertag, password ) VALUES ( :gamertag, :password )");
$stmt->bindParam(':gamertag', $_POST['gamertag']);
$stmt->bindParam(':password', $_POST['password']);
$stmt->execute();
}
###### Login USER ######
if(isset($_POST['login'])){
$gamertag = $_POST['gamertag'];
$password = $_POST['password'];
$select = $dbc->prepare("SELECT * FROM users WHERE gamertag='$gamertag' and password='$password'");
$select->setFetchMode(PDO::FETCH_ASSOC);
$select->execute();
$data=$select->fetch();
if($data['gamertag']!=$gamertag and $data['password']!=$password)
{
$message = "You entered the wrong gamertag or password";
}
elseif($data['gamertag']==$gamertag and $data['password']==$password)
{
$_SESSION['gamertag']=$data['gamertag'];
$_SESSION['email']=$data['email'];
header("Location: profile.php");
}
}
?>root/profile.php
Code:
<?
session_start();
echo var_dump($_SESSION);
?>my dbc.php is included into my index.php file where the forms are located any help would be appreciated .. thanks
![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)
















