[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cobalt-users] PHP index error



If you send me the source attached so I can read it without wondering where
line 12 is I might be able to help.

chuck

----- Original Message -----
From: "satan" <satan@xxxxxxxxxxxxxxxx>
To: <cobalt-users@xxxxxxxxxxxxxxx>
Sent: Friday, May 11, 2001 6:35 PM
Subject: [cobalt-users] PHP index error


> Hi,
> anyone know what cause this error in a php login file:
>
>
>
> Warning: Undefined index: username in /home/sites/site1/web/login.php on
> line 12
>
>
>
> I have a hosting and the script works fine there but not on my raq4 ?? Do
i
> need special setting in the php.ini file ??
>
> What can be so different on the raq4 to generate that ? Maybe i did a
> mistake changing the value, but i did not see anything.Also, the shopping
> cart stay always empty. I know this look to be more a php issues but i
> hoping someone here know the solution. It look to be related with setting
> done on cobalt raq  .
>
>
> The code is:
> **************************************************
> <?
> /* login.php (c) 2000 Ying Zhang (ying@xxxxxxxxxxxxxxx)
>  *
>  * TERMS OF USAGE:
>  * This file was written and developed by Ying Zhang
(ying@xxxxxxxxxxxxxxx)
>  * for educational and demonstration purposes only.  You are hereby
granted
> the
>  * rights to use, modify, and redistribute this file as you like.  The
only
>  * requirement is that you must retain this notice, without modifications,
> at
>  * the top of your source code.  No warranties or guarantees are expressed
> or
>  * implied. DO NOT use this code in a production environment without
>  * understanding the limitations and weaknesses pretaining to or caused by
> the
>  * use of these scripts, directly or indirectly. USE AT YOUR OWN RISK!
>  */
>
>
/***************************************************************************
> ***
>  * MAIN
>
>
****************************************************************************
> */
>
> include("application.php");
>
> /* form has been submitted, check if it the user login information is
> correct */
> if (match_referer() && isset($HTTP_POST_VARS)) {
>  $user = verify_login($HTTP_POST_VARS["username"],
> $HTTP_POST_VARS["password"]);
>
>  if ($user) {
>   $SESSION["user"] = $user;
>   $SESSION["ip"] = $REMOTE_ADDR;
>
>   /* if wantsurl is set, that means we came from a page that required
>    * log in, so let's go back there.  otherwise go back to the main page
*/
>   $goto = empty($SESSION["wantsurl"]) ? $CFG->wwwroot :
> $SESSION["wantsurl"];
>   header("Location: $goto");
>   die;
>
>  } else {
>   $errormsg = "Invalid login, please try again";
>   $frm["username"] = $HTTP_POST_VARS["username"];
>  }
> }
>
> include("$CFG->templatedir/login_form.php");
>
>
/***************************************************************************
> ***
>  * FUNCTIONS
>
>
****************************************************************************
> */
>
> function verify_login($username, $password) {
> /* verify the username and password.  if it is a valid login, return an
> array
>  * with the username, firstname, lastname, and email address of the user
*/
>
>  $qid = db_query("
>  SELECT username, firstname, lastname, email, priv
>  FROM users
>  WHERE username = '$username' AND password = '" . md5($password) . "'
>  ");
>
>  return db_fetch_array($qid);
> }
>
> ?>
>
****************************************************************************
> *
>
> \
>
>
>
>
>
>
> This is application.php
> *************************************************************
> <?
> /* application.php (c) 2000 Ying Zhang (ying@xxxxxxxxxxxxxxx)
>  *
>  * TERMS OF USAGE:
>  * This file was written and developed by Ying Zhang
(ying@xxxxxxxxxxxxxxx)
>  * for educational and demonstration purposes only.  You are hereby
granted
> the
>  * rights to use, modify, and redistribute this file as you like.  The
only
>  * requirement is that you must retain this notice, without modifications,
> at
>  * the top of your source code.  No warranties or guarantees are expressed
> or
>  * implied. DO NOT use this code in a production environment without
>  * understanding the limitations and weaknesses pretaining to or caused by
> the
>  * use of these scripts, directly or indirectly. USE AT YOUR OWN RISK!
>  */
>
> /* turn on verbose error reporting (15) to see all warnings and errors */
> error_reporting(15);
>
> /* define a generic object */
> class object {};
>
> /* setup the configuration object */
> $CFG = new object;
>
> $CFG->dbhost = "localhost";
> $CFG->dbname = "mymarket";
> $CFG->dbuser = "myuser";
> $CFG->dbpass = "mypassword";
>
> $CFG->wwwroot     = "/mymarket";
> $CFG->dirroot     = "/home/httpd/private/mymarket";
> $CFG->templatedir = "$CFG->dirroot/templates";
> $CFG->libdir      = "$CFG->dirroot/lib";
> $CFG->imagedir    = "$CFG->wwwroot/images";
> $CFG->icondir    = "$CFG->imagedir/icons";
> $CFG->bannerdir    = "$CFG->imagedir/banners";
>
> $CFG->wordlist    = "$CFG->libdir/wordlist.txt";
> $CFG->support     = "support@xxxxxxxxxxxx";
>
> /* define database error handling behavior, since we are in development
> stages
>  * we will turn on all the debugging messages to help us troubleshoot */
> $DB_DEBUG = true;
> $DB_DIE_ON_FAIL = true;
>
> /* load up standard libraries */
> require("$CFG->libdir/stdlib.php");
> require("$CFG->libdir/dblib.php");
> require("$CFG->libdir/mymarket.php");
> require("$CFG->libdir/cart.php");
>
> /* setup some global variables */
> $ME = qualified_me();
>
> /* start up the sessions, to keep things clean and manageable we will just
>  * use one array called SESSION to store our persistent variables.   */
> session_start();
> session_register("SESSION");
> session_register("CART");
>
> /* initialize the SESSION variable if necessary */
> if (! isset($SESSION)) {
>  $SESSION = array();
> }
>
> /* initialize the CART objct if necessary */
> if (! isset($CART)) {
>  $CART = new Cart;
> }
>
> /* connect to the database */
> db_connect($CFG->dbhost, $CFG->dbname, $CFG->dbuser, $CFG->dbpass);
> ?>
> ************************************************************
>
>
>
>
> thk in advance
>
> _______________________________________________
> cobalt-users mailing list
> cobalt-users@xxxxxxxxxxxxxxx
> To Subscribe or Unsubscribe, please go to:
> http://list.cobalt.com/mailman/listinfo/cobalt-users
>