PHP Login

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
brmcdani
Forum Newbie
Posts: 17
Joined: Wed Sep 02, 2009 8:21 pm

PHP Login

Post by brmcdani »

I am currently getting errors on my login PHP script. Can anyone please look over my code and see what the problem is? Attached is a code and a screen shot that I get when I run the html page on my local host. Thanks in advance.

1.<?php
2.$con = mysql_connect("localhost", "tutorial", "************");
3.mysql_select_db("tutorial", $con);
4.$q = "SELECT * FROM `logintable` WHERE user='$usernamefield' AND pass='$passwordfield'";
5.$logincheck = mysql_query($q, $con) or die("Query Error: ".mysql_error($con)."<br/>SQL: ".$q);
6.
7.if(!isset($_POST['username']) || !isset($_POST['password'])){
8. print "No username/password defined";}
9.print_r($logincheck)."<br/>"
10.print_r($rows)
11.
12.$usernamefield = $_POST['username'];
13.$passwordfield = $_POST['password'];
14.
15.$rows = mysql_fetch_array($logincheck);
16.
17.if ($rows != "") {
18. echo "Welcome please select your lake";
19.}
20.else {
21.
22.?>
23.<form id="form1" name="form1" method="post" action="">
<p>
<label>
User Name:
<input type="text" name="username" id="username" />
</label>
</p>
<p>Password:
<label>
<input type="text" name="password" id="password" />
</label>
</p>
<p>
<label>
<input type="submit" name="submit" id="submit" value="Submit" />
</label>
</p>
</form>
</body>
</html>

Image
User avatar
Weiry
Forum Contributor
Posts: 323
Joined: Wed Sep 09, 2009 5:55 am
Location: Australia

Re: PHP Login

Post by Weiry »

Your other half of this PHP Login... viewtopic.php?f=1&t=106038
Did you check the last advice in there?
brmcdani
Forum Newbie
Posts: 17
Joined: Wed Sep 02, 2009 8:21 pm

Re: PHP Login

Post by brmcdani »

Nope sure didn't I figured it was a dead post being that it was already on page 3. Thanks again for the help.
Post Reply