logo-dw

Go Back   Dreamweaver Club Forums > Dreamweaver forums > Video Tutorials
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 05-06-2007, 04:31 AM   #1
m1a2x3x7
m1a2x3x7's Avatar
 
Join Date: Mar 2007
Posts: 297
Question php login script part 2 issues

Not sure why i keep getting this warning. here is my code

Login Code

PHP Code:
<?php
require_once("connections/connect.php");
 
session_start();
 
//catch field data
$userid $_POST['userid'];
$password $_POST['password'];
$submitted $_POST['submitted'];
 
if (
$userid && $password) {
 
$query sprintf("SELECT * FROM users where user_name='$userid' and user_password = '$password'");
$result = @mysql_query($query);
$rowAccount = @mysql_fetch_array($result);
}
 
if (
$rowAccount) {
 
$_SESSION['id'] = $rowAccount['user_id'];
 
header("location:welcome.php");
exit;
 
}elseif(
$submitted){
 
echo 
"You dont exist in the system so your not getting in!";

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
 
<body>
<form id="form1" name="form1" method="post" action="<?php $_SERVER['PHP_SELF'];?>">
<table width="100" border="1" align="center">
<tr>
<td>User ID </td>
<td><input name="userid" type="text" id="userid" /></td>
</tr>
<tr>
<td>Password</td>
<td><input name="password" type="password" id="password" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="center"><input name="submitted" type="hidden" id="submitted" value="1" />
<input type="submit" name="Submit" value="Submit" /></td>
</tr>
</table>
</form>
</body>
</html>
Welcome Code

PHP Code:
<?php
require_once("connections/connect.php");
 
session_start();
 
if(! isset(
$_SESSION['id'])){
 
header("location: login.php");
exit;
}
 
$id $_SESSION['id'];
 
$query sprintf("SELECT * FROM users where user_id=$id'");
$result = @mysql_query($query);
$rowAccount = @mysql_fetch_array($result);
 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
 
<body>
Welcome to the application <?php echo $rowAccount['user_name'];?>
</body>
</html>
Connect Code

PHP Code:
<?php
///database varables///
$database "dbname";
$username "username";
$password "password";
///////////////////////
$link = @mysql_connect('localhost'$username$password);
$db mysql_select_db($database$link);
?>
These are the warning messages

Quote:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\wamp\www\lesson2\connections\connect.php:11) in C:\wamp\www\lesson2\login.php on line 4
]

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\wamp\www\lesson2\connections\connect.php:11) in C:\wamp\www\lesson2\login.php on line 4

Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\lesson2\connections\connect.php:11) in C:\wamp\www\lesson2\login.php on line 22
now I did part one of the login lesson and everything worked fine so it just has to do with the sessions and header

any and all help would be great

thanks
Chris
m1a2x3x7 is offline   Reply With Quote
Old 05-06-2007, 05:02 AM   #2
m1a2x3x7
m1a2x3x7's Avatar
 
Join Date: Mar 2007
Posts: 297
Default

never mind i just added ob_start() at the top of the login and welcome page and fixed everything
m1a2x3x7 is offline   Reply With Quote
Old 05-06-2007, 09:57 AM   #3
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

PHP Code:
echo "You dont exist in the system so your not getting in!"
where you have the above line

its better to assign warning messages to variables

this was probably the cause of the error.

try this...

PHP Code:
$warning "You dont exist in the system so your not getting in!"
then you can echo $warning where you want on the page
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 05-13-2007, 05:27 AM   #4
m1a2x3x7
m1a2x3x7's Avatar
 
Join Date: Mar 2007
Posts: 297
Default

thanks for the help mate.
m1a2x3x7 is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:33 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com