...

View Full Version : Arg whats Wrong With Meh Code???



stoodder
03-15-2003, 12:58 AM
okay guys ive made a use register for my saite it seemed to work perfectly i mean i got it to set the database and what not but now when they loggin i getthe stupid parse error!!!
heres the page if you need it: http://www.shadowgelert.com/myweb6
here is the login pages html

<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
<?php $title = "Members Login"; ?>
</head>
<body>
<form method="post" action="?page=login2">
Enter your User Name <input type="text" name="Name" size="20"><br>
Enter you Password <input type="password" name="Password" size="20"><br>
<input type="submit" name="submit">
</form>
</body>
</html>
heres the code for the page after you would hit the loggin button

<?php
$title = "Logged In";
include("common.php");

if(!($link_id = mysql_connect($Host, $User, $Pass))) die(mysql_erorr());
mysql_select_db($DB);

$sql = "SELECT ID FROM " . $Table . " WHERE Name='" . addslashes($_POST['Name']) . "' AND Password='" . md5($_POST['Password']) . "' LIMIT 1";
if(!($result = mysql_query($sql))) die(mysql_error());

if(mysql_num_rows($result) == 1) {
setcookie("LoggedIn, TRUE, time()+(3600 * 24));
echo"You Are Now Logged In";
} else {
echo"Login failure";
}
?>


I need help please

Spookster
03-15-2003, 02:40 AM
Uhhhh so what's the parse error when logging in?

stoodder
03-15-2003, 03:02 AM
well i figuered out part of it
setcookie("LoggedIn, TRUE, time()+(3600 * 24)); was suppoesed to be
setcookie('LoggedIn', 'TRUE', time()+(3600 * 24));

but i still get this new error:
Warning: Cannot add header information - headers already sent by (output started at /home/stoodder/public_html/myweb6/index.php:8) in /home/stoodder/public_html/myweb6/login2.php on line 13

Nightfire
03-15-2003, 03:22 AM
You need to set the cookies before anything is sent to the browser, and as you didn't inlcude the source for common.php, I assume you send some html to the browser with that.

stoodder
03-15-2003, 03:26 AM
hmm uh i dont really get what your saying sory./.. buit common .php has my database info in it thats all. otherwise i use index,php as my template file then i have ?page=whatever page to include into index.php im not sure if that is what you meant though please word that better.. sorry im slow lol

Nightfire
03-15-2003, 03:32 AM
From what I understand, that error means that whatever you're trying to send to the client already exists, or that you're trying to set cookies/sessions after html has been sent, ie:

<html>
<head>
<title>page</title>
</head>
<body>
<?
setcookie("LoggedIn, TRUE, time()+(3600 * 24));
echo 'blah blah';
?>
</body>
</html>

stoodder
03-15-2003, 04:18 AM
hey thanx man i got it now



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum