Jump to content


Photo

checking a users login information


  • Please log in to reply
3 replies to this topic

#1 CircularStopSign

CircularStopSign
  • Members
  • PipPipPip
  • Advanced Member
  • 44 posts

Posted 22 August 2006 - 10:46 PM

i'm still working with the membership code and there isnt a checkuser.php can anyone give me a simple code to check if the username and password match, then send them to login_success.php?

thanks in advance

#2 Corona4456

Corona4456
  • Members
  • PipPipPip
  • Advanced Member
  • 244 posts
  • LocationEl Paso, TX

Posted 22 August 2006 - 10:48 PM

http://www.phpfreaks...orials/40/5.php

There's a checkuser.php there
What is the CoronaMatrix?

#3 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 22 August 2006 - 10:49 PM

Just do it in your query.

"SELECT uname, pword FROM users WHERE uname = '{$_POST['uname']}' AND pword = '{$_POST['pword']}'";

If no results are returned they failed.

#4 SharkBait

SharkBait
  • Members
  • PipPipPip
  • Advanced Member
  • 845 posts
  • LocationMetro Vancouver, BC

Posted 22 August 2006 - 10:51 PM

<?php
$password = "mypass"
$username = "user123"

$strqry = "SELECT * FROM users WHERE password = '{$password}' AND username = '{$username}'";
$query = mysql_query($strqry) or die("MySQL Error: <br />{$strqry} <br /> ". mysql_error());
$num = mysql_num_rows($query);

if ($num < 1) {
  // Password User not found in database or do not match
} else {
  // Password/username is valid
  header("Location: login_success.php");
  exit();
}
?>

Gives you the jist of it :)





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users