RE: [PHP] problems with starting session
| From: | Daevid Vincent | Date: | Wed, 10 Dec 2003 21:33:26 +0000 |
| Subject: | RE: [PHP] problems with starting session | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-172389@lists.php.net to get a copy of this message | ||
You can't print any output before you start the session AFAIK.
Daevid Vincent
http://daevid.com
> -----Original Message-----
> From: obsidianchrysalis [mailto:obsidianchrysalis@hotmail.com]
> Sent: Tuesday, December 09, 2003 3:51 PM
> To: php-general@lists.php.net
> Subject: [PHP] problems with starting session
>
> this code snippet is used to autheticate a user's id.
> however, it generates
> errors pertaining to the script not being able to send
> headers with the
> session data.
>
> // function authenticate()
> // {
> // import variables to be read from form
> import_request_variables("p", "s_");
>
> // set variables to connect to database
> $db_host = "localhost";
> $db_user = "login_1";
> $db_pass = "addUser";
> $db_name = "jamison_id";
>
> // connect to database
> $connection = mysql_connect($db_host, $db_user,
> $db_pass) or
> die ("Unable to connect!");
> mysql_select_db($db_name);
> $query = "SELECT id_num from login WHERE user =
> '$s_user_id'
> AND passwd = '$s_passwd'";
> $result = mysql_query($query, $connection) or
> die ("Error in
> query: '$query' ." . mysql_error());
>
> // if row exists -> user/pass combination is correct
> if (mysql_num_rows($result) == 1)
> {
> $valid = 1;
> }
> else
> {
> print($s_user_id);
> print($s_passwd);
> }
> // }
> // $valid = authenticate($s_user_id, $s_passwd);
> print($valid);
> if ($valid == 1)
> {
>
> // initiate a session
> session_start();
>
> // register some session variables
> // session_register("SESSION");
>
> // including the username
> // session_register("SESSION_UNAME");
> // $SESSION_UNAME = $f_user;
> }
> ?>
>
> any help would be appreciated.
>
> chris
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>