Jump to content

Php Beginner - Login Script


p3nguin

Recommended Posts

I currently have two pages index.html and addhouse.php ... I want to able to have somebody log in to insert a new house into the database i have created .. I have the insert all figured out ...

 

However the login script is proving more difficult so far i have got

<?php

        $dbhost = 'localhost';

$dbuser = '******';

$dbpassword = '****'; // sub actual password here

$dbname = '******';

 

mysql_connect($dbhost,$dbuser,$dbpassword) or die ("Couldn't connect to database");

mysql_select_db($dbname) or die ("Couldn't select database");

$query = "SELECT * FROM users";

$result = mysql_query($query);

$row = mysql_fetch_array($result);

 

$u = login.username.value;

 

function checkUser(){

 

if($u == $row['username']){

Echo("correct");

}

}

?>

 

<form id="login" method="post" action="addhouse.php">

  <p align="center"><span class="style1"><br />

      <span class="style2">Login

      <input name="username" type="text" id="username" />

    Password

    <input name="password" type="text" id="password" />

    </span>    </span>

 

      <input type="submit" onsubmit="checkUser" name="Submit" on="on" value="Login">

 

  </p>

</form>

 

and have no idea why its not working .. any help would be appericatated

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/37287-php-beginner-login-script/
Share on other sites

hi there,

 

i posted a login system at the link below a while back. Its very simple and works very well for me. Maybe you'd find it handy. Someone did criticize it for having sql injection holes but ive fixed that since!

 

Anyways its here:

 

http://www.sitepoint.com/forums/showthread.php?t=454528

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.