I am a beginner when it comes to php so need help. I am using php code for a promotional code box to redirect customers to a new URL, so they input the code in a promo box on my home page which then redirects them to the special URL page with special offers. I now need to provide a large number of codes for a promotion we are going to run, all the codes need to be unique so I was wondering if there was a way to develop a 6 digit code where the first 4 digits only are recognised by the php script (this will be the same on all codes), and the last 2 digits are ignored when the customer enters their unique code in the box?? So we give the customer a 6 digit code but the script just uses the first 4 digits and ignores the last 2.
The code I am using is:
[php]<?php
$errmsg = “”;
if (empty($_POST[‘pcode’])) {
$errmsg = ‘Enter promotional code’;
include ‘promoform.php’;
} else {
switch($_POST[‘pcode’]) {
case “code123”:
$redirectpage = ‘http://www.website.com’;
break;
case “code456”:
$redirectpage = ‘http://www.website.com’;
break;
}
header(“Location: $redirectpage”);
}
?>
[/php]Any suggestions are welcome, thanks.