last day (14 days later) » 

6:17 AM
1
A: Undefined Variable MySQL PHP

Ralph MelhemIn your init.php, You're only initializing user_data if the user is logged in. Based on the logic in your header.php, it should be like that: if(!logged_in()){ ?> <a>USER</a> <ul> <li><a href="./login">SIGN IN</a></li> <li><a href="./register">REGISTER</a></li> </ul> <?php }else{ ?> <a><...

 
I have already fixed this problem (in the above comment, you will see)
 
Can you edit your question and apply the code that you're actually using and are you still getting the same error?
 
@RalphMelham I just did so :) yes, I am still getting an error. It appears my login function doesn't work and Is the reason It is not displaying the username e.t.c. Do you think you might be able to help with that? thanks
 
@nerdtweak Sure thing I can help you troubleshoot and fix it. Are you getting a specific error? How did you know your problem lies in the login function?
 
well, it's not actually outputting an error, however, when the user logs in, it's supposed to display the username rather than "user". therefore, the actual login function isn't working, otherwise, logged_in would return the user_id rather than false (if that makes sense)
 
6:17 AM
Well you'll need to add flags throughout your code to see which step isn't working properly. Before doing that, please change all the "=== false" identifiers to ! (ie: instead of "if(empty($username) === true)", use if(empty($username))). Then add echo "stepName"; *replace stepName by the actual step name so you know how your code is running and which if/else it's accessing. Once you do that, we can see flaws in the process if there are any, and if not, we'll see on which function it's stopping, and debug it
 
nothing happens :(
 
are you here?
You cannot see the output of echo because it's redirecting. comment out your header(location ) function for now so we can check the output
 
yep
oh, the echos are fine
it's still not working though :/
 
okay, but based on the echoes, is your code going into the login function correctly? and after that where is it going?
Don't expect it to magically work, we need to debug it, be patient :D
 
... ok so I am a bit confused (sorry
)
where should I put all my echoes
 
6:21 AM
Everywhere, This is basically your way of making your code talk to you
Do you want to send me your code as a zip file and your database so i can replicate the issue here and help you better?
 
ok
I have just figured it out
so, It is, in fact, working and redirecting me to the home page correctly. however. it must be a problem in the USERS.php file as code is being sent through correctly. :/
 
are you working on localhost?
 
yes...
 
6:42 AM
can you send me your project so i can debug it for you?
Sorry was helping someone else
 

last day (14 days later) »