Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

Log in problem

Codes here !

Moderators: macek, egami, gesf

Log in problem

Postby Pearl » Wed Jun 05, 2013 2:33 pm

To whom is this concern
I make website where i have registration page and log in page.I made database of course,but i have problem with log in page.I register my self and notification came one e-mail with activation link and i see in database all registration information and going o log in page is said "No match in our records, try again".
Log in code is


<?php
/*
Created By @ www.flashbuilding.com
----------------------June 20, 2008-----------------------
*/
if ($_POST['email']) {
//Connect to the database through our include
include_once "connect_to_mysql.php";
$email = stripslashes($_POST['email']);
$email = strip_tags($email);
$email = mysql_real_escape_string($email);
$password =preg_replace ("[^A-Za-z0-9]", "", $_POST['password']); // filter everything but numbers and letters
$password = md5($password);
// Make query and then register all database data that -
// cannot be changed by member into SESSION variables.
// Data that you want member to be able to change -
// should never be set into a SESSION variable.
$sql = mysql_query("SELECT * FROM members WHERE email='$email' AND password='$password' AND emailactivated='1'");
$login_check = mysql_num_rows($sql);
if($login_check > 0){
while($row = mysql_fetch_array($sql)){
// Get member ID into a session variable
$id = $row["id"];
session_register('id');
$_SESSION['id'] = $id;
// Get member username into a session variable
$username = $row["username"];
session_register('username');
$_SESSION['username'] = $username;
// Update last_log_date field for this member now
mysql_query("UPDATE members SET lastlogin=now() WHERE id='$id'");
// Print success message here if all went well then exit the script
header("location: member_profile.php?id=$id");
exit();
} // close while
} else {
// Print login failure message to the user and link them back to your login page
print '<br /><br /><font color="#FF0000">No match in our records, try again </font><br />
<br /><a href="login.php">Click here</a> to go back to the login page.';
exit();
}
}// close if post
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Login to your profile</title>
<script type="text/javascript">
<!-- Form Validation -->
function validate_form ( ) {
valid = true;
if ( document.logform.email.value == "" ) {
alert ( "Please enter your User Name" );
valid = false;
}
if ( document.logform.pass.value == "" ) {
alert ( "Please enter your password" );
valid = false;
}
return valid;
}
<!-- Form Validation -->
</script>
</head>
<body>
<div align="center">
<h3><br />
<br />
Log in to your account here<br />
<br />
</h3>
</div>
<table align="center" cellpadding="5">
<form action="login.php" method="post" enctype="multipart/form-data" name="logform" id="logform" onsubmit="return validate_form ( );">
<tr>
<td class="style7"><div align="right">Email Address:</div></td>
<td><input name="email" type="text" id="email" size="30" maxlength="64" /></td>
</tr>
<tr>
<td class="style7"><div align="right">Password:</div></td>
<td><input name="password" type="password" id="password" size="30" maxlength="24" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input name="Submit" type="submit" value="Login" /></td>
</tr>
<?php

?>


</form>
</table>
</body>
</html>
Pearl
New php-forum User
New php-forum User
 
Posts: 4
Joined: Wed Jun 05, 2013 2:04 pm

Re: Log in problem

Postby johnj » Wed Jun 05, 2013 8:33 pm

please print this sql, SELECT * FROM members WHERE email='$email' AND password='$password' AND emailactivated='1'" and then use a database client like phpmyadmin and run it against your database and see if it actually picks the record that you want.
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: Log in problem

Postby Pearl » Thu Jun 06, 2013 7:53 am

To whom is this concern

I am not sure what i have to do.Do you have some video with this instructions if not can you please explain details step by step where to go and what to do, please print this sql, SELECT * FROM members WHERE email='$email' AND password='$password' AND emailactivated='1'" and then use a database client like phpmyadmin and run it against your database and see if it actually picks the record that you want.


Thanks
Pearl
New php-forum User
New php-forum User
 
Posts: 4
Joined: Wed Jun 05, 2013 2:04 pm

Re: Log in problem

Postby Pearl » Thu Jun 06, 2013 7:59 am

Pearl
New php-forum User
New php-forum User
 
Posts: 4
Joined: Wed Jun 05, 2013 2:04 pm


Return to mySQL & php coding

Who is online

Users browsing this forum: No registered users and 4 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron