Ok, I am stuck. I have the following code to log in. I don't think it is 100% secure, but I am having an issue writing a script that will email a link for a user to reset their password. Any help would be appreciated...
<?php
session_start();
if(isset($_GET['reg'])) {
$reg=$_GET['reg'];
}
else
{
$reg="";
}
if($reg==1) {
$msg1="<font color=\"#FF0000\"><b>Your details have been added, please login</b></font>";
} elseif($reg==2) {
$msg1="<font color=\"#FF0000\"><b>You have been successfully logged out.</b></font>";
}
if(isset($_POST['submit'])) {
if( empty($_POST['uname']) && (empty($_POST['upass']))) {
header( "Location:core/Messages.php?msg=1" );
exit();
}
//transfer to shorter var
$n=$_POST['uname'];
$p=$_POST['upass'];
//connect to db
require_once('core/db.php');
$query="select uname, pw from _admin where uname='$n' and pw='$p' ";
$result=mysql_query($query);
$num=mysql_num_rows($result);
if($num>0 ){
//put in session vars
$_SESSION['status'] = 'logged';
$_SESSION['username'] = $n;
//goto next page
header("location:main.php");
exit;
} else {
$_SESSION['status'] = 'not logged';
header( "Location:core/Messages.php?msg=2" );
exit();
}
}
?>