Re: session/header problem (warning:newbie with sessions)
| From: | Ernest E Vogelsinger | Date: | Sat, 17 May 2003 18:50:45 +0000 |
| Subject: | Re: session/header problem (warning:newbie with sessions) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-148037@lists.php.net to get a copy of this message | ||
At 18:49 17.05.2003, Ryan A said:
--------------------[snip]--------------------
>Notice: Undefined variable: row in
>c:\phpdev\www\bwh\co.authenticate.login.php on line 19
>
>Notice: Undefined variable: row in
>c:\phpdev\www\bwh\co.authenticate.login.php on line 20
You didn't assign anything to $row - PHP informs you that you're reading
the value from an not existing variable, hence retrieve null. It does this
just to help you finding out while your code isn't working. See comments
below, within the code.
>Warning: Cannot add header information - headers already sent by (output
>started at c:\phpdev\www\bwh\co.authenticate.login.php:19) in
>c:\phpdev\www\bwh\co.authenticate.login.php on line 21
This is triggered by the two preceding warnings - output (the warnings)
have already been sent. It will disappear when the other problems are solved.
>this is my tiny code:
><?php
> error_reporting (E_ALL);
> include_once("configbwh.php");
>
>$user= $_POST["user"];
>$pass= $_POST["pass"];
>
>if(isset($user) && $user && isset($pass) && $pass)
>{
>$connected=mysql_connect ("$hostt", "$userr", "$passs") or die
>('I cannot
>connect to the database because: ' . mysql_error());
>mysql_select_db ("$db");
>
>$database["sql"] = " select user,pass from main_co where
>user='".$user."'
>and pass='".$pass."'";
>
>$result = mysql_query($database["sql"]) or die("Error: " .
>mysql_error());
>if(mysql_num_rows($result) == 1)
> {
You should retrieve the $row here, I believe...
$row = mysql_fetch_row($result);
> session_start();
Have the call to session_start() at the very beginning of your script so it
will always run with a session...
> $_SESSION['user'] = $row[15];
> $_SESSION['pass'] = $row[16];
> header("Location:co.details.php");
> exit;
> }
> }
>?>
>
>what am i doing wrong?
Have I been clear enough? Hopeso,
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/