0

I've made a little progress but become stuck with some PHP code. I have a small database of codes, which I need a PHP form field to check against and then direct the visitor to one of two pages depending whether what they type into that field matches a record or not.

So far it works, but with a few problems, I'm looking to find out how to;

1. Get the PHP to ignore any spaces
2. Ignore any capitalization
3. Direct the visitor to seperate html pages

The page is here - http://www.bhurd.co.uk/test_checker.php

and the PHP which makes it work;

$postcodecheck = $_POST['postcode'];
$check = mysql_query("SELECT pc FROM ".$db_prefix."another WHERE pc = '$postcodecheck'")
or die(mysql_error());

$check2 = mysql_num_rows($check);
//if the PC exists it gives a message
if ($check2 != 0) {
die('That Postcode '.$_POST['postcode'].' is <strong class="highlight">eligible</strong> ');
}
 elseif ($check2 == 0) {
    
    print("<font color='#FF0000'>You are not eligible.</font>");
    }
2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by nav33n
0

What do you mean by ignore spaces ? Do you want to remove spaces ? If yes, use, str_replace function to replace a space with null. You can use strtolower function to convert capital letters to lower case. Lastly, Use header function for redirection.
Note: You shouldn't output anything before calling header function. If you have no other go, but to call header function, use ob_start(). :)[html tag, echo statement, or even a space] before calling header function. If you have no other go, but to call header function, use ob_start(). :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.