Wirral Posted March 24, 2008 Share Posted March 24, 2008 Hi I am trying to make a php login for a website using MS access database. I don't want the users to register I want to give them pre set passwords and usernames here is my code so far can some one tell me were I am going wrong and If i am linking it to the database properly thanks. <php // Connects to your Database mysql_connect("your.hostaddress.com", "username", "password") or die(mysql_error()); mysql_select_db("login") or die(mysql_error()); if(isset($_COOKIE['ID_my_site'])) { $username = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); while ($info = mysql_fetch_array( $check )) { if ($pass != $info['password']) { } else { header("Location: members.php"); } } } if (isset($_POST['submit'])) { // if form has been submitted // makes sure they filled it in if(!$_POST['username'] | !$_POST['pass']) { die('You did not fill in a required field.'); } if (!get_magic_quotes_gpc()) { $_POST['email'] = addslashes($_POST['email']); } $check = mysql_query("SELECT * FROM users WHERE username = '".$_POST['username']."'")or die(mysql_error()); $_POST['pass'] = stripslashes($_POST['pass']); $info['password'] = stripslashes($info['password']); $_POST['pass'] = md5($_POST['pass']); //gives error if the password is wrong if ($_POST['pass'] != $info['password']) { die('Incorrect password, please try again.'); } else { // if login is ok then we add a cookie $_POST['username'] = stripslashes($_POST['username']); $hour = time() + 3600; setcookie(ID_my_site, $_POST['username'], $hour); setcookie(Key_my_site, $_POST['pass'], $hour); //then redirect them to the members area header("Location: members.php"); } } } else { // if they are not logged in ?> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <table border="0"> <tr><td colspan=2><h3>Login</h3></td></tr> <tr><td>Username:</td><td> <input type="text" name="username" maxlength="40"> </td></tr> <tr><td>Password:</td><td> <input type="password" name="pass" maxlength="50"> </td></tr> <tr><td colspan="2" align="right"> <input type="submit" name="submit" value="Login"> </td></tr> </table> </form> <?php } Thanks Link to comment https://forums.phpfreaks.com/topic/97698-php-login/ Share on other sites More sharing options...
uniflare Posted March 24, 2008 Share Posted March 24, 2008 are you trying to use MS or mysql? for MS ACCESS im pretty sure you need to use odbc_connect() rather than mysql_connect, mysql_ functions are specifically for use with a MySQL Database. Link to comment https://forums.phpfreaks.com/topic/97698-php-login/#findComment-499920 Share on other sites More sharing options...
ohdang888 Posted March 24, 2008 Share Posted March 24, 2008 and just curcious... Why would you want to give the, preset usernames? Link to comment https://forums.phpfreaks.com/topic/97698-php-login/#findComment-499921 Share on other sites More sharing options...
Wirral Posted March 24, 2008 Author Share Posted March 24, 2008 Am using Ms access and yeah I am pretty clueless with all of this but any help or direction would be helped please. As for the preset passwords its part of the requirements and would be easier to implement surely its only for a small quanity of users as well i.e. 10. thanks Link to comment https://forums.phpfreaks.com/topic/97698-php-login/#findComment-499927 Share on other sites More sharing options...
uniflare Posted March 24, 2008 Share Posted March 24, 2008 http://uk2.php.net/odbc_connect further down on that page is a comment leading to http://www.phpfreaks.com/tutorials/61/0.php hope this helps, --- Link above is invalid (the comment on php.net will need to be updated OR this webserver will need to redirect to the new link. from the old link) the new link is: http://www.phpfreaks.com/forums/index.php/topic,186679.0.html Link to comment https://forums.phpfreaks.com/topic/97698-php-login/#findComment-499929 Share on other sites More sharing options...
Wirral Posted March 24, 2008 Author Share Posted March 24, 2008 Thanks for that although I am a total newb with any form of coding so if some one would be willing to hold my hand through this that would be amazing. Link to comment https://forums.phpfreaks.com/topic/97698-php-login/#findComment-499932 Share on other sites More sharing options...
Wirral Posted March 25, 2008 Author Share Posted March 25, 2008 Can some one please help me with this as i am lost if they would be willing to start me off with the code or do it (cheeky i know) I would be delighted. Anyone?? Link to comment https://forums.phpfreaks.com/topic/97698-php-login/#findComment-500021 Share on other sites More sharing options...
ohdang888 Posted March 25, 2008 Share Posted March 25, 2008 i know mysql, not ms. most people in this forum are mysql Link to comment https://forums.phpfreaks.com/topic/97698-php-login/#findComment-500057 Share on other sites More sharing options...
uniflare Posted March 25, 2008 Share Posted March 25, 2008 http://www.configure-all.com/php_access.php Link to comment https://forums.phpfreaks.com/topic/97698-php-login/#findComment-500059 Share on other sites More sharing options...
Wirral Posted March 25, 2008 Author Share Posted March 25, 2008 but how would I apply that to a login script??? Link to comment https://forums.phpfreaks.com/topic/97698-php-login/#findComment-500311 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.