Link to home
Start Free TrialLog in
Avatar of Catcherman16
Catcherman16Flag for United States of America

asked on

php login page not working properly

i am unable to figure it out guys...

My login page doesn't work. i get ZERO output not even an error. so im begging for some help!! thanks in advance!!

Below is my login form and the php script.
<table>	  
<form method=post action=ehlogin.php>
<tr><td>Username:</td><td><input type=text name=username></td></tr>
<tr><td>Pass:</td><td><input type=password name=pass></td></tr>
<tr><td colspan=2 align=center><input type=submit value=Login></td></tr>
</form>
</table>
 
 
<?php
 
if( isset($_POST['Login']) && strval($_POST['Login'])=='Login' )
{
 
 
include("config.php"); 
 
 
 
// connect to the mysql server 
$link = mysql_connect($server, $db_user, $db_pass) 
or die ("Could not connect to mysql because ".mysql_error()); 
 
// select the database
mysql_select_db($database) 
or die ("Could not select database because ".mysql_error()); 
 
$match = "select id from $table where username = '".$_POST['username']."' 
and password = '".$_POST['password']."';"; 
 
$qry = mysql_query($match) 
or die ("Could not match data because ".mysql_error()); 
$num_rows = mysql_num_rows($qry); 
 
if ($num_rows <= 0) { 
echo "Sorry, there is no username or password with: <strong>".$_POST['username']."</strong><br>"; 
echo "<a href=login.html>Try again</a>"; 
exit;
 
} else { 
 
setcookie("loggedin", "".$_POST['username']."", time()+(3600 * 24));
setcookie("username", "".$_POST['username']."", "TRUE");
echo "Welcome: <strong>".$_POST['username']."</strong><br>"; 
echo "Continue to the <a href=members.php>members</a> section."; 
}
 
 
}
?>

Open in new window

Avatar of hielo
hielo
Flag of Wallis and Futuna image

I just posted a login page here:
https://www.experts-exchange.com/questions/23892100/Creating-a-login-logout-component-for-my-php-pages-using-mysql.html

you should be able to make minor changes to suit your needs.
Let's work on the basics here.

Set error_reporting(E_ALL);

Use var_dump() to print out $_POST

See what the name of your submit button is.
Also, you might want to use phpinfo() and see if you are running in safe mode or something like that.
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial