Jump to content

Login php


isharie

Recommended Posts

<!DOCTYPE HTML>
<html>


<head>
<title>Fife council</title>
<meta name="viewport" content="width=device-width, initial-scale=1"> 
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
</head> 
<body>






<div data-role="header">
<h1>Fife council</h1>
</div>


<div data-role="navbar">
<ul>
<li><a href="register.php" data-transition="flip">Register</a></li>
<li><a href="index.php" data-transition="flip">Home</a></li>
</ul> 
</div><!-- /navbar --> 
<div data-role="content" data-id="cont">


<?php
if (isset($_POST['password'], $_POST['username']))
{
$username = strtolower(strip_tags($_POST['username']));
$password = strip_tags($_POST['password']);
$connect = mysql_connect("localhost","root","");




{
if (empty ($username) || empty($password))
{
$errors[] ='All fields are required';
}
$query = mysql_query("SELECT username FROM users WHERE username ='$username'"); 
$numrows = mysql_num_rows($query);
if ($numrows <1)
{
$errors[] ='Please enter a valid username';
}


$query = mysql_query("SELECT password FROM users WHERE username ='$username'"); 
$numrows = mysql_num_rows($query);
if ($numrows <1)
{
$errors[] ='Invalid password';
}
if(!empty($errors))
{
foreach ($errors as $errors)
{
echo '<strong>',$errors ,'</strong><br />';
}
}else{
if ($username&&$password)
{


$connect = mysql_connect("localhost","root","") or die ("Could not connect");
mysql_select_db ("mobile") or die ("Could not find database");


$query = mysql_query("SELECT * FROM users WHERE username ='$username'");


$numrows = mysql_num_rows($query);
if ($numrows !=0)
{
while ($row =mysql_fetch_assoc($query))
{
$dbusername = $row['username'];
$dbpassword = $row['password'];
}


if ($username==$dbusername&&$password==$dbpassword)
{
echo header( 'Location: member.php' ) ;
$_SESSION['username']=$dbusername;
} 
}
}


} 
}
}
?>




<div id ="loginForm" align="center"> 
<fieldset data-role="fieldcontain">
<form id='login' action='' method='post' accept-charset='UTF-8' data-transition="flip"">
<fieldset>
<input type='hidden' name='submitted' id='submitted' value='1'/>
<label for='username' >UserName*:</label>
<input type='text' name='username' id='username'  maxlength="50" />
<label for='password' >Password*:</label>
<input type='password' name='password' id='password' maxlength="50" />
<input type='submit' name='Submit' value='Submit'/>
</fieldset>
</form>
</div>
</div><!-- /content --> 


<div data-role="footer" data-id="foo1">
<h1>Footer</h1>
</div><!-- /footer --> 


</body> 
</html>

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in E:\EasyPHP-12.1\www\my portable files\mobilelo1\loginform.php on line 41

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in E:\EasyPHP-12.1\www\my portable files\mobilelo1\loginform.php on line 48
Please enter a valid username
Invalid password

 

 

Error messages 

 

It should only display error massages and it should let me log in, it's not letting me do anything at the moment any advice would be good.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.