Hey everyone I just started using a new hosting service called 1and1 all the normal pages are going fine that use the simple html extension. However one of my php pages that uses the session_start() and header() functions isnt working correctly and I get an error. Now I know an error usually occurs if you have the session_start() below any html code. However I made sure to keep my session_start() and most of my php code above the html. I even tried moving all of it above the html. However I still get the error. Here is my code in its current state: (all areas that have sensitive have been censored of course)
<?
session_start();
//attempts to connect to DB if it cannot, produces error message
if( !($conn= @mysql_connect("******","*****","****")))
{
die("Connection Failed");
}
//attempts to select DB if it cannot, produces error message
if(!mysql_select_db("*****",$conn))
{
die("Selection Error");
}
//pulls information from the user form
$user = $_REQUEST['user'];
$pass = $_REQUEST['pass'];
//encrypts password
$pass= md5($pass);
//creates the query that will check if the user is actually in the database
$userQ = "SELECT uname FROM `users` WHERE uname = '$user' AND pass = '$pass'";
?>
<?php
//checks to see if the information supplied by the user matches a name in the database. If not kicks the user to the blamnation page
if(mysql_num_rows(mysql_query($userQ,$conn)))
{
//creates an array for the page
$userInfo = array();
//takes the variables from the session and puts them into an array
$userInfo['name'] = $user;
$userInfo['pass'] = $pass;
//creates an array that will fill the array created above with the data from the databse
$fillQ= mysql_query("SELECT uID,xlive,steam,psn,bio,avatar,email FROM users WHERE uname = '$user' AND pass = '$pass'",$conn);
//fills in the userInfo array with all info on user from database
while($row = mysql_fetch_assoc($fillQ))
{
$userInfo['id'] = $row['uID'];
$userInfo['picture'] = $row['avatar'];
$userInfo['email'] = $row['email'];
$userInfo['xlive']= $row['xlive'];
$userInfo['psn']= $row['psn'];
$userInfo['steam']=$row['steam'];
$userInfo['bio'] = $row['bio'];
}
//confirmation text that is displayed to the user if the login is successful
$_SESSION['userInfo'] = $userInfo;
echo"<div style='width:400px; background-color:#3A3636; margin-left:380px; height:150px;'>";
echo"<address style='background-color:orange; color:white; font-family:Impact; font-size:25pt;'>Welcome Back!</address>";
echo"<center>";
echo "<br> <span style='color:white; font-family:calibri; font-size:12pt;'>Congrats <b>$user</b> you are now logged in </span> <br>";
echo " <a style='font-family:calibri; font-size:12pt; color:red;' href='blam.php'>Go to Homepage </a> <br>'";
echo " <a style='font-family:calibri; font-size:12pt; color:red;'href='profile.php?profile=$user'>Go To Your Profile </a> <br>";
echo "<a style='font-family:calibri; font-size:12pt; color:red;' href='pedit.php'> Edit Your Profile</a>";
echo" </center>";
echo"</div>";
}
else
{
header('location:blamnation.php');
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- Script that runs to log the user in -->
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Login</title>
</head>
<body>
<br/>
<!-- creates a box that holds the login confirmation text -->
</body>
</html>
any help guys would be greatly appreciated! thanks!