This is a discussion on "Login/register" within the PHP Forum section. This forum, and the thread "Login/register are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Login/register
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
||||
|
Re: Login/register
yes:
is the query correct? i wasn't too sure on it
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
||||
|
Re: Login/register
okay, i don't get a blank page anymore but it doesn't change when the user logs in:
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
|||
|
Re: Login/register
ok try this
on every page, at the top, put: print_r ($_SESSION); tell me what you get, if anything. |
|
|||
|
Re: Login/register
and also, try to make it more obvious what you are looking for, i.e
<?php $form = "<form action=\"/User/login.php\" method=\"post\">Username:<br><input type=\"text\" name=\"user\"><br>Password:<br> <input type=\"password\" name=\"pass\"><br> <p align=\"center\"><input type=\"submit\" action=\"submit\" name=\"login\" value=\"login\"> </p> </form><p>Haven't got an account? Register</p><p>Forgot your password?</p>"; if (!isset($_SESSION['usersession'])){ echo $form; echo "TEST 1"; } else {//IS logged in $doquery=mysql_query("select * from users where username='$username'"); echo "TEST 2"; echo mysql_error() or die(mysql_error() ); while($nt=mysql_fetch_array($doquery)){ echo "hello $nt[username]"; } } ?> Last edited by Voodoochilli; Jul 30th, 2007 at 23:36. |
|
||||
|
Re: Login/register
Array ( [usersession] => [count] => 593 )
count was a little test i did to check if sessions where working. and i will try that other one now thanks
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
||||
|
Re: Login/register
only test 1 appeared.
does that mean there's something wrong with the query?
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
|||
|
Re: Login/register
it means the php interpreter isnt getting to that bit, meaning, your code is broken before that point. ie after TEST 1 and before TEST 2, so we know where the problem is!
|
|
||||
|
Re: Login/register
yes and the part between is:
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
|||
|
Re: Login/register
try changing
$doquery=mysql_query("select * from users where username='$username'"); to echo "test 3"; if that works then we know there a MYSQL error. Also don't you use a mysql link identifier, I mean my mysql quries look like: mysql_query("select * from users where username='$username'", $dl ); |
|
||||
|
Re: Login/register
i don't know what a link identifier does to be honest.
and umm changing it to echo test 3 made no difference :/
you know in this part: Array ( [usersession] => [count] => 593 ) does that mean that usersession doesn't contain anything? should't it say something like [usersession] = alex ?
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
||||
|
Re: Login/register
ahh in the login script, i didn't assign the $username variable to anything.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
|||
|
Re: Login/register
I will have to check this tomorrow, its too late for me to think php right now (2 am) Promise I will have a think in the morning for you.
|
|
||||
|
Re: Login/register
sorry to keep you up!
thank you!
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
|||
|
Re: Login/register
morning
ok Array ( [usersession] => [count] => 593 ) means there is something stored in it. print_r() is very useful to know if an array contains anything. putting that in: echo "test 3"; echo "TEST 2"; was silly of me, must have been tired. you only need 1 echo. can you echo the $username variable at the top to make sure it contains something ? |
|
|||
|
Re: Login/register
also shouldn't echo "hello $nt[username]";
be echo "hello $nt['username']"; Does it even echo the hello part? |
|
||||
|
Re: Login/register
right i've changed the session to "loggedin"
adding the '' to the echo made a blank page, and i don't know why i have a blank page because my php.ini says to display errors. anyway this is the code i'm using: (still not sure if the query is right.)
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
||||
|
Re: Login/register
right new one.
this is sort of working. i think there's a problem with the "while" part though :/
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
||||
|
Re: Login/register
got it working
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
|||
|
Re: Login/register
$query = "SELECT * FROM users WHERE username='alexgeek' ";
$result = mysql_query($query) or die(mysql_error()); // Print out the contents of each row into a table while($row = mysql_fetch_array($result)){ echo $row['username']. " - ". $row['score']; echo "<br />"; ha! you did the 2 things I was going to suggest! Put the or die in the query, not after, then add '' to the var name! |
![]() |
| Tags |
| alexgeek, cs3, dreamweaver, login, mysql, php, register |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PHP Login Register help | atlaskid | PHP Forum | 6 | Nov 10th, 2006 21:34 |
| some type of member login/register system | Lucid. | Web Page Design | 22 | Feb 3rd, 2006 17:19 |