Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

php login page not working properly

Posted on 2008-11-10
4
Medium Priority
?
202 Views
Last Modified: 2012-05-05
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

0
Comment
Question by:Catcherman16
  • 3
4 Comments
 
LVL 82

Expert Comment

by:hielo
ID: 22926301
I just posted a login page here:
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_23892100.html

you should be able to make minor changes to suit your needs.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 22926448
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.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 22926457
Also, you might want to use phpinfo() and see if you are running in safe mode or something like that.
0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 1500 total points
ID: 22926508
And if you're still looking for illumination, check this tutorial:
http://www.sitepoint.com/article/users-php-sessions-mysql/

Best regards, ~Ray
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month20 days, 21 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question