Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Problems with redirecting code

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Problems with redirecting code

Postby tonylara » Tue May 14, 2013 4:58 am

I need to keep track of sells rep. once client puts in their referal code, they will be redirected to the reps payment page

I have 2 php files:

First files code:
<!--referal_by.php-->
<form method="post" action="send_to_referal.php">
Enter Referal Code here.<br />
<input type='text' name='salesrep'><br />
Leave it blank if you don't have one.<br />
<input name="submit" type="submit" value="BOOK NOW" />
</form>


Second files code to redirect to Sales Rep payment is:
<?php
$salesrep = $_POST['salesrep'];
if ($salesrep == 'Dan') {
$name = 'http://www.reps_url.com';
}
elseif ($salesrep == 'Sally') {
$name = 'http://www.reps_url.com';
}
else ($salesrep != '') {
$name = "<h1>Code not on file</h1>
UPPERCASE and lowercase matters make sure it was just as you saw it<br />
use your browsers back to try again";
}
echo $name;
?>

any help on this?
tonylara
New php-forum User
New php-forum User
 
Posts: 1
Joined: Tue May 14, 2013 4:53 am

Re: Problems with redirecting code

Postby johnj » Tue May 14, 2013 5:48 am

please read about header() function in php.
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: Problems with redirecting code

Postby daveismyname » Wed May 15, 2013 10:52 pm

try it like this:

Code: Select all
<?php
$salesrep = $_POST['salesrep'];
if ($salesrep == 'Dan') {
   //redirect
   header('Location: http://www.reps_url.com');
   exit;
}
elseif ($salesrep == 'Sally') {
   //redirect
   header('Location: http://www.reps_url.com');
   exit;
}
else ($salesrep != '') {
$name = "<h1>Code not on file</h1>
<p>UPPERCASE and lowercase matters make sure it was just as you saw it<br />
use your browsers back to try again</p>";
}
?>
User avatar
daveismyname
New php-forum User
New php-forum User
 
Posts: 26
Joined: Sat Oct 15, 2011 3:21 am
Location: Hull, East Yorkshire, England


Return to PHP coding => General

Who is online

Users browsing this forum: Baidu [Spider], Google [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron