I am even less proficient with php than a beginner, so go easy on the laughter. I had code written that doesn’t work properly and it may be due to the order of certain code (purely a guess). This code is supposed to check for valid user login and redirect to another page, refund_letter.php, if the visitor is a valid user, but it goes to a page not found error. If anyone can spot the problem and offer a solution, thanks in advance.
[php]
<?php session_start(); if(isset($_COOKIE["err_count"]) && $_COOKIE["err_count"] > 2){ header("Location: http://lslostandfound.com/contact-us/"); // url to send after failing thrice. this file is in public_html/lslostandfound.com/wp-content/themes/footer-mod-2 } if($_POST['client_info_3']) { $q_rows = mysql_num_rows(mysql_query("SELECT * FROM Client_info WHERE lower(fname) = '".strtolower($_POST['fname'])."' AND refcode = '".$_POST['refcode']."'")); if($q_rows >= 1) { $_SESSION['fname'] = $_POST['fname']; $_SESSION['refcode'] = $_POST['refcode']; header("Location: http://lslostandfound.com/process/refund_letter.php"); // url to send after login } else{ $error = "Invalid combination of full name and refcode, Please try again.."; if(!isset($_COOKIE["err_count"])){ setcookie("err_count",1,time()+604800,'/'); }else if(isset($_COOKIE["err_count"]) && $_COOKIE["err_count"] > 2){ header("Location: http://lslostandfound.com/contact-us/"); }else if(isset($_COOKIE["err_count"]) && $_COOKIE["err_count"] <= 2){ setcookie("err_count",$_COOKIE["err_count"]+1,time()+604800,'/'); } } } ?> <?php /* Template Name: Page-login */ ?> <?php get_header(); ?> <?php get_sidebar('top'); ?>
<?php
if (have_posts()) {
/* Start the Loop */
while (have_posts()) {
the_post();
get_template_part('content', 'page');
echo "<span style='color:red'>$error</span>";
/* Display comments */
if (theme_get_option('theme_allow_comments')) {
comments_template();
}
}
} else {
theme_404_content();
}
?>
<?php get_sidebar('bottom'); ?>
<?php get_footer(); ?>[/php]