p3nguin Posted February 6, 2007 Share Posted February 6, 2007 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 More sharing options...
trq Posted February 6, 2007 Share Posted February 6, 2007 Your trying to mix javascript and php. This cannot be done as Javascript runs client side, while php runs server side. You can't call a php function via javascripts onsubmit. Nor will php recognside javascript variables. Link to comment https://forums.phpfreaks.com/topic/37287-php-beginner-login-script/#findComment-178190 Share on other sites More sharing options...
p3nguin Posted February 6, 2007 Author Share Posted February 6, 2007 Ah okie ... if i seperate the javascript and the php from each other is that all the code i will need for it to work or is there something i have missed ? Link to comment https://forums.phpfreaks.com/topic/37287-php-beginner-login-script/#findComment-178193 Share on other sites More sharing options...
trq Posted February 6, 2007 Share Posted February 6, 2007 Well the logic itself is also a little off. Id'e have a look and see if you can find a decent tutorial on the subject. there should be something on our main site. Link to comment https://forums.phpfreaks.com/topic/37287-php-beginner-login-script/#findComment-178200 Share on other sites More sharing options...
jimmi8 Posted February 6, 2007 Share Posted February 6, 2007 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 Link to comment https://forums.phpfreaks.com/topic/37287-php-beginner-login-script/#findComment-178208 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.