• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

Undefined error in PHP

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm getting two errors detailed below:



And my code is:


And I don't know how to fix it and I've been stuck on it for some time.
 
Bartender
Posts: 3648
16
Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your current PHP code is fetching some data from a login form and then execute the "login" function.

The errors are complaining about these 2 lines


You need a HTML form with the action pointing to your PHP file.
 
tommy yeend
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems to be okay when I first login, but the error appears when I go back to the page
 
K. Tsang
Bartender
Posts: 3648
16
Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Honestly such script should only run once, successful or not. Upon success, redirect to the appropriate page. Upon failure, redirect to the login form, prompting the error eg invalid password or similar.
 
tommy yeend
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The script does work as when I log in, it directs me to the page and there's no errors. But when I go to another page once logged in and return to the member page (which the script is for), it provides the error
 
K. Tsang
Bartender
Posts: 3648
16
Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting. Then that page/script is somewhat poorly written.

Login form -> that PHP script (run login) -> member page (no problem) -> another page -> member page (problem)

One solution I can think of is check whether the variables are present in the $_SESSION or $_POST before assigning values.



At the end the subsequent call to member page the if statement (username && passwd) needs to be false
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic