Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: Issues with PHP & mySQL
11-14-2013, 10:48 PM #1
- Join Date
- Nov 2013
- Thanked 0 Times in 0 Posts
Issues with PHP & mySQL
Me and a few friends are attempting to creating a social network with a YouTube tutorial. In this specific video, https://www.youtube.com/watch?v=Ooxe6TPt8vM, we are having trouble. When the user puts in the correct credentials, it gives an error message and will not accept those credentials. The PHP debugging says this "Notice: Undefined index: user_login in [--site directory--]/inc/incfiles/header.inc.php on line 6". The mySQL database can be read and can be seen as the login creds are in the system. The user_login index is defined in the index.php file
Here are the links to our code~
11-15-2013, 12:03 AM #2
- Join Date
- Sep 2002
- Saskatoon, Saskatchewan
- Thanked 2,668 Times in 2,637 Posts
The notice itself is not the problem. That is caused by attempting to read from the $_SESSION superglobal without having the data in it. The next line indicates what you should do; you must always use isset() to verify something exists before attempting to read from it. So the problem itself is elsewhere.
So what you should see happen is as such. When you hit the index.php page the first time for the session, you should see an error with undefined index (which can be fixed with the isset check). Then, you should login and it should take you back to the index without the notice. That's if its functioning properly.
Find this in index.php:
$_SESSION["id"] = $id;
$_SESSION["user_login"] = $user_login;
$_SESSION["password_login"] = $password_login;
Also, you should change <? to <?php. Short form notation is a feature of the language, and is not guaranteed to be available on every server. <?php will always work. Try searching as well for tutorials built in at least 5.2+ as well (I didn't see this link here, but there's some oldish stuff), things like the mysql library are now obsolete; they are replaced with the mysqli library and PDO is another option.
header('HTTP/1.1 420 Enhance Your Calm');
Users who have thanked Fou-Lu for this post: