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
Merger of 6 sister companies under one flagship company after go live
Dear Experts,
I need one help regarding Merger of sister companies of same group. currently we
WORDPRESS - Multiple Loops Only Going to One Post?
I have various pages with multiple loops and i need them to be individual to all other categories.
php redirecting
i wont open a new thread but i have a question about redirecting....
i wonder why my code doesnt
Alternate messaging
I have 4 strings in MySQL db1
$string1 : Hello
$string2 : Hi
$string3 : Great
$strin
post to self
Trying to get my form to submit to itself. However I am also trying to use an image for my submit bu
Header is not working in IE
Hi ! header function is not working in IE but it works in FF, Safari, Chrome. any help please. :
query help
Hi experts.
i have a table rep2 like this
PROD_COD ACCT_NO DUE_DAYS BALANCE
count only commas outside parenteses
I have a sql table containing
id - query - query name
the first page contains a drop down men
get the country of visitor and display content based on that
Hello all,
I have seen that Google analytics can tell you where a visitor is coming from and
Mysterious Timeouts
I've deployed a few simple AJAX-enabled web page to a local server that is accessed through the Inte