vardaloupas Posted January 23, 2011 Share Posted January 23, 2011 Hello I try to made a login page but i have problems.... login.html page <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form name="form1" method="post" action="checklogin.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong>Member Login </strong></td> </tr> <tr> <td width="78">Username</td> <td width="6">:</td> <td width="294"><input name="myusername" type="text" id="myusername"></td> </tr> <tr> <td>Password</td> <td>:</td> <td><input name="mypassword" type="password" id="mypassword"></td> </tr> <tr> <td width="78">Status</td> <td width="6">:</td> <td> <select name="mystatus"> <option value="Admin">Admin</option> <option value="Technician">Technician</option> <option value="AirTrafficController">Air traffic controller</option> </select> </td> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Login"></td> </tr> </table> </td> </form> </tr> </table> </body> </html> AND check_login.php page <?php ob_start(); $host="localhost"; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name="ergasia2"; // Database name $tbl_name="EMPLOYEES"; // Table name $status=""; // Connect to server and select databse. mysql_connect("$host", "$username", "$password", "$status")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Define $myusername and $mypassword $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; $status = $_POST['mystatus']; if($count==1){ if ($_POST['mystatus'] == 'root') { header("location:".admin.html); } elseif ($_POST['mystatus'] == 'vassilis'){ header("location:".controler.html); } elseif ($_POST['mystatus'] == 'vassilis'){ header("location:".technician.html); } else { echo "Wrong Username or Password"; } } ob_end_flush(); ?> The first problem is I can't connect with database but when I m trying to check with a script everything is ok.... <?php $link = mysql_connect("localhost","root","123"); if(! $link) die("Could not connect to MySQL"); else print("Connected to MySQL server<P>"); $database = "ergasia2"; mysql_select_db($database) or die ("could not open $database: ".mysql_error() ); print "Opened database \"$database\"<P>"; mysql_close($link); print "Everything works"; ?> The results of previous script. Connected to MySQL server Opened database "ergasia2" Everything works Quote Link to comment Share on other sites More sharing options...
trq Posted January 23, 2011 Share Posted January 23, 2011 The problem is what? Quote Link to comment Share on other sites More sharing options...
vardaloupas Posted January 23, 2011 Author Share Posted January 23, 2011 Ok first problem is can't connect, as I explained before the connection problem must be problem of php not of Mysql. Quote Link to comment Share on other sites More sharing options...
trq Posted January 23, 2011 Share Posted January 23, 2011 But the output you have presented say you CAN connect? Quote Link to comment Share on other sites More sharing options...
vardaloupas Posted January 23, 2011 Author Share Posted January 23, 2011 I made a php check script and works but with my login page not. Quote Link to comment Share on other sites More sharing options...
ZulfadlyAshBurn Posted January 23, 2011 Share Posted January 23, 2011 nothing is gonna happen unless you change <form name="form1" method="post" action="checklogin.php"> to <form name="form1" method="post" action="check_login.php"> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.