Forgot Password / Register
Site Statistics
Total Members: 520
Total Tutorials: 242
Newsest User: 8884244477
Todays Unique Hits: 429
0 Users 5 Guests Online
Forum Index » PHP + MySQL » Loggin in Problem
Posted on Friday 8th June 2007 at 07:20 AM
MCP
templates/default/images/noavatar.png's Avatar
Junior Member
On login.php when I log in it says "Logging In..." and then back to the login form. I have restarted my browser, cleared all the cookies and crap. Still nothing.

It was working fine earlier.
Here is the code. Maybe you'll be able to spot the problem.

login.php
PHP Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
session_start
(); //allows session
include "config.php";
echo 
"<left>";

if(
$logged[id]){
//welcomes the member
echo "<b><em>Welcome $logged[username]</em></b><br>";
//shows the user menu
echo "
<table width='100%' border='0' cellpadding='0' cellspacing='0'>
<tr>
  <td><table width='100%' border='0' cellspacing='6' cellpadding='0'>
<tr>
  <td><b>Members</b></td>
  </tr>
<tr>
  <td><a href='editprofile.php'>Edit Profile</a></td>
  </tr>
<tr>
  <td><a href='changepassword.php'>Change Password</a></td>
  </tr>
<tr>
  <td><a href='chpin.php'>Change PIN</a></td>
  </tr>
<tr>
  <td><a href='members.php'>Members</a></td>
  </tr>
<tr>
  <td><b>Admin</b></td>
  </tr>
<tr>
  <td><a href='admin.php'>Admin Panel</a></td>
  </tr>
<tr>
  <td><b><a href='logout.php?logout'>Logout</a></b></td>
  </tr>
<tr>
  <td>&nbsp;</td>
</tr>
<tr>
  <td><strong>UPCOMING FEATURES</strong></td>
</tr>
<tr>
  <td>Forum (Next two or three days)</td>
</tr>
<tr>
  <td>PM</td>
</tr>
</table></td></tr>
</table>"
;
}
else
if(
$logged[pincode]==123){ 
//checks if pincode is default 
echo ("<p class='error'>Your pincode is the default pincode (123) Please change it.</p><meta http-equiv=\"refresh\" content=\"5;url=chpin.php\">");
//redirects to the configure pincode

else
//if there trying to login
if(isset($_GET['login'])){
//removes sql injections from the data
$usernamehtmlspecialchars(addslashes($_POST[username])); 
//encrypts the password
$password sha1(md5(md5(sha1(md5(sha1(sha1(md5($_POST[password]))))))));
//gets the username data from the members database
$uinfo mysql_query("SELECT * FROM `members` WHERE `username` = '$username'") or die(mysql_error()); 
//see if the user exists
$checkuser mysql_num_rows($uinfo);
//if user name not found in database error
if($checkuser == '0')
{
echo 
"<p class='error'>Username not found</p>";
}
else
{
//fetch the sql
$udata mysql_fetch_array($uinfo);
//checks see if the account is verified
if($udata[userlevel] == 1) { 
echo 
"<p class='error'>This account has not been verified</p>";
}
//if it is continue
else
//if the db password and the logged in password are the same login
if($udata[password] == $password) {
$query mysql_query("SELECT * FROM `members` WHERE `username` = '$username'") or die(mysql_error()); 
//fetchs the sql
$user mysql_fetch_array($query);
//sets the logged session
$_SESSION['id'] = "$user[id]";
$_SESSION['password'] = "$user[password]";

echo 
"Logging In...";
//redirects them
echo "<meta http-equiv='Refresh' content='2; URL=login.php'/>";
}
//wrong password
else
{
echo 
"<p class='error'>Incorrect username or password!</p>"
}
}
}
else
{
//If not the above show the login form
echo "<form action='login.php?login' method='post'>
<table width='312'>
  <tr>
    <td width='120'>Username:</td>
    <td width='180'><input type='text' name='username' size='30' maxlength='25'></td>
  </tr>
  <tr>
    <td>Password:</td>
    <td><input type='password' name='password' size='30' maxlength='25'></td>
  </tr>
    <tr>
    <td colspan='2'><left><input type='submit' value='Login'>
               <a href=\"register.php\">Register</a> | <a href=\"forgotpass.php\">Forgot Password</a></left></td>
  </tr>
</table>
</form>"
;
}
echo 
"<left>";
?>
Posted on Friday 8th June 2007 at 04:54 PM
gbt91
templates/default/images/noavatar.png's Avatar
Junior Member
O.o It seems to be right...
lol
Posted on Friday 8th June 2007 at 07:20 PM
Diablosblizz
templates/default/images/noavatar.png's Avatar
Senior Member
If this is not your full page and you have CSS infront of it then remove the CSS and put it below.

Also, may I ask what <em> is?
Posted on Friday 8th June 2007 at 09:58 PM
MCP
templates/default/images/noavatar.png's Avatar
Junior Member
<em>Test</em> = Text

It stands for emphasis. Italics provides emphasis.
Posted on Friday 8th June 2007 at 10:01 PM
MCP
templates/default/images/noavatar.png's Avatar
Junior Member
Nope. Ok I will post the code for the entire thing. You try finding something.

login.php
PHP Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>FFiH News</title>
<link rel='stylesheet' type='text/css' href='../css/style.css' /><script type='text/javascript' src='../js/include.js'></script>
<script type='text/javascript' src='../js/uf.js'></script>
</head>
<body>
<table cellpadding='0' cellspacing='0' width='100%' height='100%'>
    <tr>
        <td align='center'>

            <table cellpadding='0' cellspacing='0' id='sideGradient'>
<tr><td align='center'><div id='header'></div></td></tr>
<tr><td align='center'>
    <table cellpadding='0' cellspacing='0' width='879'>
    <tr><td id='tabsHolder'>
        <table cellpadding='0' cellspacing='0' width='100%'><tr>
        <td width='66%' valign='bottom'><table width="416" cellpadding='0' cellspacing='0' id='tab'>
          <tr>
            <td width="11" class='unselLeft' />        
            <td width="80" class='unselMid'><div align="center"><a href='../index.html'>FFiH News</a></div></td>
            <td width="13" class='unselRight' />        
            <td width="11" class='unselLeft' />        
            <td width="85" class='unselMid'><div align="center"><a href='http://www.youtube.com/FFiH'>FFiH YouTube</a></div></td>
            <td width="13" class='unselRight' />        
            <td width="11" class='unselLeft' />        
            <td width="67" class='unselMid'><div align="center"><a href='../forum/'>The Forum</a></div></td>
            <td width="13" class='unselRight' />        
            <td width="11" class='selLeft' />        
            <td width="89" class='selMid'><div align="center"><a href='login.php'>Members Area </a></div></td>
            <td width="10" class='selRight' />        
            <!-- <td align='right'><font color="#888888">10.10.10.2</font></td> -->
          </tr>
          </table></td>
        </table>
    </td></tr>
    </table>
</td></tr>
<tr><td align='center' height='100%' class='bodyHolder'>
    <table cellpadding='0' cellspacing='0' height='100%' width='878'>
        <tr><td valign='top'>
        <div class="style4" id='alerts'>. </div>

        <table cellpadding='0' cellspacing='0'><tr>
            <td width='126' valign='top' id='navCol'><table cellpadding='0' cellspacing='0' width='120'>
              <tr>
                <td class='navTitle'><br>
                    <br>
                    <br>
                  Main</td>
              </tr>
              <tr>
                <td class='nav'><div class='navLink'><a href='../index.html'>News</a></div></td>
              </tr>
              <tr>
                <td class='nav'><div class='navLink'><a href='../aboutmcp.html'>About MCP</a></div></td>
              </tr>
              <tr>
                <td class='nav'><div class='navLink'><a href='../cast.html'>Cast</a></div></td>
              </tr>
              <tr>
                <td class='nav'><div class='navLink'><a href='../videos.html'>Videos</a></div></td>
              </tr>
              <tr>
                <td class='nav'><div class='navLink'><a href='../comics.html'>Comics</a></div></td>
              </tr>
              <tr>
                <td height='15' />            
              </tr>
              <tr>
                <td class='navTitle'>Community</td>
              </tr>
              <tr>
                <td class='nav'><div class='navLink'><a href='../forum/'>The Forum</a></div></td>
              </tr>
              <tr>
                <td class='nav'><div class='navLink'><a href='../members/login.php'>Member Area </a></div></td>
              </tr>
              <tr>
                <td class='nav'><div class='navLink'><a href='../members/members.php'>Memberlist</a></div></td>
              </tr>
              <tr>
                <td height='15' />            
              </tr>
              <tr>
                <td class='navTitle'>Current Episode</td>
              </tr>
              <tr>
                <td style="padding-bottom: 5px;" align="center"><a href="ep1.html"><img src="../css/imgs/random/ep1.jpg" alt="" width="110" height="110" border="0"></a></td>
              </tr>
            </table></td>
            <td width='754' id='pageContent' valign='top'>
<table cellpadding='0' cellspacing='0' width='100%'><tr><td class='spacer'>
        <table cellpadding='0' cellspacing='0' width='100%'><tr><td width='90%' valign='top' style='padding-left:8px;'></td><td>

        <a href='#bottom'><img src='../css/imgs/downRight.gif' width="12" height="8" border="0" style='float:right' /></a>
        </td>
        </tr></table>
        </td></tr><tr><td><table cellpadding='0' cellspacing='0' width='100%'><tr><td class='content' width='100%' valign='top'>
            <table cellpadding='0' cellspacing='0' width='100%'>
                <tr>
                    <td>
            <div class='post'>
                <table width='100%' cellpadding='0' cellspacing='0'>
                    <tr>

                        <td><h2 class="style2">Member Area</h2>
                          <p><?php
session_start
(); //allows session
include "config.php";
echo 
"<left>";

if(
$logged[id]){
//welcomes the member
echo "<b><em>Welcome $logged[username]</em></b><br>";
//shows the user menu
echo "
<table width='100%' border='0' cellpadding='0' cellspacing='0'>
<tr>
  <td><table width='100%' border='0' cellspacing='6' cellpadding='0'>
<tr>
  <td><b>Members</b></td>
  </tr>
<tr>
  <td><a href='editprofile.php'>Edit Profile</a></td>
  </tr>
<tr>
  <td><a href='changepassword.php'>Change Password</a></td>
  </tr>
<tr>
  <td><a href='chpin.php'>Change PIN</a></td>
  </tr>
<tr>
  <td><a href='members.php'>Members</a></td>
  </tr>
<tr>
  <td><b>Admin</b></td>
  </tr>
<tr>
  <td><a href='admin.php'>Admin Panel</a></td>
  </tr>
<tr>
  <td><b><a href='logout.php?logout'>Logout</a></b></td>
  </tr>
<tr>
  <td>&nbsp;</td>
</tr>
<tr>
  <td><strong>UPCOMING FEATURES</strong></td>
</tr>
<tr>
  <td>Forum (Next two or three days)</td>
</tr>
<tr>
  <td>PM</td>
</tr>
</table></td></tr>
</table>"
;
}
else
if(
$logged[pincode]==123){ 
//checks if pincode is default 
echo ("<p class='error'>Your pincode is the default pincode (123) Please change it.</p><meta http-equiv=\"refresh\" content=\"5;url=chpin.php\">");
//redirects to the configure pincode

else
//if there trying to login
if(isset($_GET['login'])){
//removes sql injections from the data
$usernamehtmlspecialchars(addslashes($_POST[username])); 
//encrypts the password
$password sha1(md5(md5(sha1(md5(sha1(sha1(md5($_POST[password]))))))));
//gets the username data from the members database
$uinfo mysql_query("SELECT * FROM `members` WHERE `username` = '$username'") or die(mysql_error()); 
//see if the user exists
$checkuser mysql_num_rows($uinfo);
//if user name not found in database error
if($checkuser == '0')
{
echo 
"<p class='error'>Username not found</p>";
}
else
{
//fetch the sql
$udata mysql_fetch_array($uinfo);
//checks see if the account is verified
if($udata[userlevel] == 1) { 
echo 
"<p class='error'>This account has not been verified</p>";
}
//if it is continue
else
//if the db password and the logged in password are the same login
if($udata[password] == $password) {
$query mysql_query("SELECT * FROM `members` WHERE `username` = '$username'") or die(mysql_error()); 
//fetchs the sql
$user mysql_fetch_array($query);
//sets the logged session
$_SESSION['id'] = "$user[id]";
$_SESSION['password'] = "$user[password]";

echo 
"Logging In...";
//redirects them
echo "<meta http-equiv='Refresh' content='2; URL=login.php'/>";
}
//wrong password
else
{
echo 
"<p class='error'>Incorrect username or password!</p>"
}
}
}
else
{
//If not the above show the login form
echo "<form action='login.php?login' method='post'>
<table width='312'>
  <tr>
    <td width='120'>Username:</td>
    <td width='180'><input type='text' name='username' size='30' maxlength='25'></td>
  </tr>
  <tr>
    <td>Password:</td>
    <td><input type='password' name='password' size='30' maxlength='25'></td>
  </tr>
    <tr>
    <td colspan='2'><left><input type='submit' value='Login'>
               <a href=\"register.php\">Register</a> | <a href=\"forgotpass.php\">Forgot Password</a></left></td>
  </tr>
</table>
</form>"
;
}
echo 
"<left>";
?> </p></td>
                    </tr>
                </table>
            </div></td></tr>
                    </table></td></tr>
                    </table></td></tr>
                    </table></td>    
                    </tr></table>
                    </td></tr>
                
        <tr><td valign='bottom' align='right' style='padding-top:36px'>
        <a name='bottom' />
        
        <table cellpadding='0' cellspacing='0' width='754'>
        <tr><td style='padding-bottom:10px;text-align:center;background:url(../css/imgs/toTop.gif) 50% 2px no-repeat'>
                <a href='#top' class='small'>Back to Top</a>
        </td>
        </tr><tr><td class='small' style='padding-bottom:10px;text-align:center'><p><a class='small' href='../contact.html'>Contact Information</a><br>
                <br>
  © 2007 MESSCast Productions.<br>
          Based on Halo © 1985-2001 Microsoft Corporation.  All rights reserved.<br>
          Microsoft, Bungie and Halo are trademarks of Microsoft Corporation.<br>
          Read our <a class="small"  href="../privacy.html" target="_blank">Privacy Policy</a>.</p>
            </td>
        </tr>
        <tr>
          <td class='small' style='padding-bottom:10px;text-align:center'><br>
            <table cellpadding='0' cellspacing='0' width='100%'>
            <tr>
              <td width='38%' />          
              <td width='25%' align='center' class="small"><a href="http://corporategreen.net/"><img src="http://rvb.roosterteeth.com/assets/images/cg.gif" alt="" width="187" height="25" border="0"><br>
                <br>
              </a>Customized by MESSCast Productions</td>
              <td width='37%' align='right'>&nbsp;</td>
            </tr>
          </table></td>
          </tr>
        </table>
        
        </td></tr>
    </table>
</td></tr>
</table>
</td></tr></table>
<head><style type="text/css">
<!--
.style2 {
    color: #910000;
    font-size: 16px;
}
.style4 {color: #FFFFFF}
.style5 {
    font-size: 14px;
    font-weight: bold;
    color: #910000;
}
.style7 {color: #E0E0E0}
-->
</style></head>
<script type='text/javascript' src='../js/wz_tooltip.js'></script>
</body>
</html>
Posted on Friday 8th June 2007 at 10:23 PM
SkillMaster
templates/default/images/noavatar.png's Avatar
Senior Member
Thats like a layout in the login system.

Separate the two then try.
Posted on Saturday 9th June 2007 at 12:46 AM
MCP
templates/default/images/noavatar.png's Avatar
Junior Member
What do you mean? The login system is in the layout not the other way around.

I have a hunch. I will report in a minute.
Posted on Saturday 9th June 2007 at 12:48 AM
MCP
templates/default/images/noavatar.png's Avatar
Junior Member
Ok I removed all the layout stuff. It works now. Crap. Now I have to remake the page code. haha Ok This thread is dead now since I know how to fix it. Thanks.
Posted on Saturday 9th June 2007 at 01:21 AM
SkillMaster
templates/default/images/noavatar.png's Avatar
Senior Member
lol its k
Posted on Saturday 9th June 2007 at 02:31 AM
MCP
templates/default/images/noavatar.png's Avatar
Junior Member
OK All I did was paste in the code from another page. It is a bit different but the code is now not affecting the login page.

Thanks for the tips.