sineadyd Posted April 24, 2008 Share Posted April 24, 2008 Hi, Can anyone spot errors that I may have missed here because its really annoying me!I have a "users" db and tables for "admin","members" and "register" in it.I will only be using members and admin for this script, but whatever it is, it just will not connect to the database. any help would be really reeeeeally appreciated! Thanks in advance! <?php //Users Database settings $host="localhost"; $username="root"; $password=""; $db_name="users"; //Connect to server and select database. $dbc= mysql_connect("$host","$username","$password") or die("connection was unsuccessful"); $dbc= mysql_select_db($db_name)or die("Database connection was unsuccessful"); if (is_null($dbc) && !(is_resource($dbc))) { die('Error getting connection.'); } //User database tables needed. // $tbl_memb="members"; // $tbl_admin="admin"; //create and issue the query $username=$_POST['USERNAME']; $password=$_POST['PASSWORD']; $sqlmemb="SELECT * FROM members WHERE username = '$username' and password='$password'"; $resultmemb= mysql_query($sqlmemb) or die(mysql_error()); //get the number of rows in the result set //should be 1 if theres a match $isset1=mysql_num_rows($resultmemb); $sqlamin="SELECT * FROM admin WHERE username='$username' and password='$password'"; $resultadmin= mysql_query($sqlamin) or die(mysql_error()); //get the number of rows in the result set // should be 1 if theres a match $isset2=mysql_num_rows($resultadmin); //------------// //member login// //------------// //If isset1(members login) is equal to 1 then the members homestart page is opened. if($isset1==1) { ?> <script language="javascript"> window.open('../www/homestart.htm','', config='scrollbars=yes,menubar=no,height=850,width=955,resizable=yes,status=yes')</script> <?php //create display string $display_block=" <p> ".$username." is authorised!</p>"; include 'Login.html'; } //-----------// //admin Login// //-----------// else if ($isset2==1) //If admin details are correct then it will open the administrators homestart page is opened. { ?> <script language="javascript"> window.open('../admin/homestart.htm','', config='scrollbars=yes,menubar=no,height=850,width=955,resizable=yes,status=yes')</script> <?php //create display string $display_block=" <p> ".$username." is authorised!</p>"; include 'Login.html'; } //------------// //Redirection// //-----------// else if ($isset1==0 OR $isset2==0)//If the username enters wrong details then an error is displayed { // and they are redirected back to the login page. echo '<html>'."n".'<body><div class="disfunction">Sorry, the Username and password you have entered are incorrect!</div></body>'."n".'</html>'; include 'Login.html'; exit; } //set authorisation cookie setcookie("auth", "1", 0, "/","Login.html", 0); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>successlogin.php</title> </head> <body> <?php echo "$display_block";?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/102688-solved-login-script-help/ Share on other sites More sharing options...
Pino Posted April 24, 2008 Share Posted April 24, 2008 So the connection was unsuccessful error is displayed? Link to comment https://forums.phpfreaks.com/topic/102688-solved-login-script-help/#findComment-525886 Share on other sites More sharing options...
sineadyd Posted April 24, 2008 Author Share Posted April 24, 2008 No, I tested it yesterday and it said "No database selected" now today its just asking to open the actual login.php script, bt I havent changed anything. Link to comment https://forums.phpfreaks.com/topic/102688-solved-login-script-help/#findComment-525887 Share on other sites More sharing options...
sineadyd Posted April 24, 2008 Author Share Posted April 24, 2008 ok ive got it to stop wanting to open the actual script, but all its giving me now is "the username and password are incorrect!" but its not connected to the database and its not throwing up any specific mysql errors. Link to comment https://forums.phpfreaks.com/topic/102688-solved-login-script-help/#findComment-525891 Share on other sites More sharing options...
Xoom3r Posted April 24, 2008 Share Posted April 24, 2008 Are you testing it on your computer with Xampp? Link to comment https://forums.phpfreaks.com/topic/102688-solved-login-script-help/#findComment-525893 Share on other sites More sharing options...
sineadyd Posted April 24, 2008 Author Share Posted April 24, 2008 No im using wamp5 and I'm using internet explorer browser to test it. Link to comment https://forums.phpfreaks.com/topic/102688-solved-login-script-help/#findComment-525896 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.