Login script (probably a simple error)
Posted on
16th Feb 2014 07:03 pm by
admin
dbConfig.php
Code: <?
// Replace the variable values below
// with your specific database information.
$host = "localhost";
$user = "username";
$pass = "password";
$db = "annarbo1_Archives";
// This part sets up the connection to the
// database (so you don't need to reopen the connection
// again on the same page).
$ms = mysql_pconnect($host, $user, $pass);
if ( !$ms )
{
echo "Error connecting to database.n";
}
// Then you need to make sure the database you want
// is selected.
mysql_select_db($db);
?>
login.php
Code: <?php
// dBase file
include "dbConfig.php";
session_start();
if ($_GET["op"] == "login")
{
if (!$_POST["username"] || !$_POST["password"])
{
die("You need to provide a username and password.");
}
// Create query
$q = "SELECT * FROM `people` "
."WHERE `username`='".$_POST["username"]."' "
."AND `password`=PASSWORD('".$_POST["password"]."') "
."LIMIT 1";
// Run query
$r = mysql_query($q);
if ( $obj = @mysql_fetch_object($r) )
{
// Login good, create session variables
$_SESSION["valid_user"] = $_POST["username"];
// Redirect to member page
Header("Location: index.php");
}
else
{
// Login not successful
die("Sorry, could not log you in. Wrong login information.");
}
}
?>
when I run this online i get this error:
"Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home4/annarbo1/public_html/login.php:2) in /home4/annarbo1/public_html/login.php on line 4"
I have yet to figure out what's wrong
No comments posted yet
Your Answer:
Login to answer
115
28
Other forums
problem with php server update from mid 2009
Hi,
I have this navigation menu on 2 websites which used to work just fine. After a recent up
Displaying different page content, depending on the logged in user.
Hi all, I am new to ASP.net (and web development in general), and have a question about how I can di
Strange PHP/mySQL error ... am I just tired?
Code: <?
## CONNECT TO DB FUNCTION!
function ConnectTo($db2con)
{
$hostNam
timezone change with date()
so i put all my times for posts in my made from scratch forum(not phpbb3 or sm)
in my mysql db u
$_GET problem
Hi all,
Have a bit of a problem with a little piece of code, I am not sure if this should be
need help modifying script
Hi guys,
I'm fairly new to php and am having a bit of trouble modifying a script.
This
Do something every fifth time?
I'm trying to write a loop, but I want it to do something different after every fifth instance. Like
Problem in String replace program's output
Hi all,
I was trying to make a program which accepts a string and replaces it with another stri
Help with syntax
Hi all!
The $bridge variable is not getting passed while it is contained in the line below:
Multiple PHP errors when clicking a link..and..removing a ghost..
Hi - I have 2 problems with a new website - homeswapvacations.com, which I need help solving.