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
simple ping code
been searchin the site/web and found code thats simple but doesnt work.
I have a personal we
Calculus Help (and by help I mean homework)
Hrmmm, I hate posting about math homework, partly because it's homework, and partly because I hate w
Do not allow posting of whitespace
Currently the script below works if the user does not type a name/message, but if i create a whitesp
Dump with added_funcion cl_salv_table
Hi there, I'm having some troubles adding a self defined function to an ALV in fullscreen. The thing
SESSION CHECK WORKS "MOST" of the time... whats going on?
i have a sign in check thats included in every page that is a members only page which is basically a
How do I create a 2D game "camera" to follow player?
In J2ME programming I'm targeting MIDP 2.0 devices.
I'm using gamecanvas and I was thinking t
Using insert variable
need a way to inert variable data to mysql database
$acc = "212121212";
$nok =
Connect to database that isn't localhost
I am currently doing a small script for a company that doesn't have mySql support on there hosting.
$_POST
Hi, I have 2 seperate php files, and i want my $_POSt["fname"] To go into both of them, Fo
What am I missing here? Help!
Hello all!. I can't seem to get this working right. Well - it renders right, but something is goin