//recover script for both Username And Password //$email = ''; //for declar global variable if ($_SERVER["REQUEST_METHOD"] == "POST") { $email = mysql_real_escape_string(htmlentities(input_validation($_POST['email']))); $type = mysql_real_escape_string(htmlentities(input_validation($_GET['type']))); $type_allowed = array('ForgotPassword'); if (isset($type) === true && in_array($type, $type_allowed) === true) { if (empty($email) === true) { $errors[] = 'You need to enter your email address which you have used for Signup'; } elseif (filter_var($email, FILTER_VALIDATE_EMAIL) === false) { $errors[] = 'A valid email addres is required.'; } if (email_exists($con, $email) === false) { $errors[] = 'Oops, we can\'t recognize you. Please try again'; } else { recover($con, $email, $type); // same function user for recover both Username And Password $_SESSION['recover_password_email'] = $email; //for success message check //for Logout user log; $remark = 'Recover login details.'; insert_user_log($con, user_id_from_email($con, $email), 9, REMOTE_IP, $remark); if ($_GET['type'] == 'ForgotPassword') { header('Location: auth.php?type=ForgotPassword&Success'); exit; } } } //array check } //end isset
if (!$insert_query) { echo "Opps! Data not inserted./e"; } else { //for user log; if ($allow_log == 1) { $remark = 'New article category added'; insert_user_log($con, $_SESSION['user_id'], 4, REMOTE_IP, $remark); } echo "Data was inserted Successful!"; } } else { $update_query = mysql_query("UPDATE article_category SET ac_name = '{$ac_name}', ac_code='{$ac_code}' WHERE art_cat_id = '{$art_cat_id}'"); if (!$update_query) { echo "Opps! Data not updated./e"; } else { //for user log; if ($allow_log == 1) { $remark = 'Article category updated'; insert_user_log($con, $_SESSION['user_id'], 5, REMOTE_IP, $remark); } echo "Data was update Successful!"; } } } //end preg } else { echo "Star mark field are required./e"; } //end empty */ } //end isset
echo 'Invalid username/password combination'; } else { if ($query_num_rows == 1) { $id = mysql_result($query_run, 0, 'id'); //setting the user id into the variable '$id' $username = mysql_result($query_run, 0, 'username'); //setting the user id into the variable '$id' $name = mysql_result($query_run, 0, 'name'); //setting the user id into the variable '$id' $_SESSION['id'] = $id; //starting a session with the user id $_SESSION['username'] = $username; //starting a session with the user id $_SESSION['name'] = $name; //starting a session with the user id insert_user_log($id); header('Location:home.php'); //redirecting the page into 'profile.php' exit; } } } } else { echo 'You must supply a username and password.'; } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">