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
Protecting forms
Alright, I want to protect some forms of mine from SQL Injections, because I had someone earlier spa
help connecting a form to php and then emailing the form
Ok. So, I made a form, and I need help to where when submitted, I get an email with the submitted de
Javascript using window.location seems to lose state
Not sure what forum so let me know if I'm in the wrong place.
I have a main window with a ajax grid
Automatic Webpage ??
I have a page www.mysite.com/test.php with a
<form>
<textarea name=&q
Can you help please? Php file
I have to write this php file to allow users to register their nicknames on nickserv
For an I
Remove letter from numeric textbox
I have a textbox that will search the employee database by entering in the employee ID and it will r
Help on code output
My CODE:
Code: [Select] echo "<phone>".$line["phone"].&qu
function to return url
Hi,
Can you guys help me giving a function that takes all the contents in a particular field
admin with my register system?
Hey i wana make it so i can make a admin level on my register system , I'm kinda new to php to im no
problem getting my contact form working
Yeah I know this is a pretty basic problem, but it's been a while since I've worked with PHP and I'm