Click to See Complete Forum and Search --> : Coding question


maryb
07-13-2006, 03:29 PM
I'm not sure which language you would write this in or how to go about it. I would like to have an input box on my page so the user can input a code. And this would redirect the code to another page that would be printable. I would need this code to show on the printable page. It would be printing a coupon, the code would signify where the user came from so it would be important.

Could someone point me in the right direction?

Thanx in advance.

ray326
07-13-2006, 11:45 PM
Sounds like an input box on a form. You'll need some server side processing to handle the form and generate the response page for printing.

pcthug
07-14-2006, 04:00 AM
Most server-side languages could easily accomodate such, a simple php example:
<?php
if(isset($_POST['inputBoxCode']) && !empty($_POST['inputBoxCode'])) {

// Here we define our possible codes and there respectful printable pages.
$c = array('Code1' => 'http://mydomain.com/printable.php?coupon=code1',
'Code2' => 'http://mydomain.com/printable.php?coupon=code2',
'Code3' => 'http://mydomain.com/printable.php?coupon=code3');]

switch($_POST['inputBoxCode']) {
case 'Code1':
header("Location: $c['code1']");
break;

case 'Code2':
header("Location: $c['code2']");
break;

case 'Code3':
header("Location: $c['code3']");
break;

default:
echo 'Invalid Coupon Code';
exit;
}

}
else {
echo 'Bad Request';
exit;
}
?>

Then on the printable page we will use the following php code to identify the coupon code:Coupon Code: <?php echo $_GET['coupon'] ?>