/    Sign up×
Community /Pin to ProfileBookmark

Coding question

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.

to post a comment
Full-stack Developer

2 Comments(s)

Copy linkTweet thisAlerts:
@ray326Jul 14.2006 — 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.
Copy linkTweet thisAlerts:
@pcthugJul 14.2006 — Most server-side languages could easily accomodate such, a simple php example:
[code=php]<?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;
}
?>[/code]


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

Success!

Help @maryb spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...