/    Sign up×
Community /Pin to ProfileBookmark

Newbie having trouble directing to a URL based on user input.

I am trying to re-direct users to specific URLs depending on their input from another page. Code listed below:

<?php
$user1=999;
$user2=100;
$user3=200;
$url=’http://www.espn.com‘;

$account=$_POST[“account”];

if ($account==$user1)
{
header (‘Location: /support.html’);
exit;
}
elseif ($account==$user2)
{

header(‘Location: /services.html’);
exit;

}
elseif ($account==$user3)
{
header(‘Location: /about.html’);
exit;
}
else
{
echo “this don’t work”;
}
?>

I have also tried (‘Location: [url]http://mydomain.com/about.html’);[/url] and to no avail.

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@BezzzZFeb 12.2014 — two questions

1) are you sure the code is executing
<i>
</i>if ($account==$user1)
{
echo 'user1';
exit;
}
elseif ($account==$user2)
{
echo 'user2';
exit;
}
elseif ($account==$user3)
{
echo 'user3';
exit;
}
else
{
echo "this don't work";
}


2) is error reporting on, if so are you getting any errors ?
Copy linkTweet thisAlerts:
@NogDogFeb 12.2014 — Are you getting the "this doesn't work" message, or some other result? If you are getting that message, then it's time to do a var_dump of $_POST and see if 'account' is actually set in it, and what it's exact value is. (Maybe you should be using $_GET?)
Copy linkTweet thisAlerts:
@aubenefitFeb 13.2014 — hi, you can remove the "exit" in command. No need it.

If your value is the same 999, 100 , 200, it will redirect well. If not it shows "this don't work".

Please post message error if you get......
Copy linkTweet thisAlerts:
@NogDogFeb 13.2014 — Looking back at this, did you mean to use that $url variable as part of the redirect?
<i>
</i>header ('Location: [B][COLOR="#FF0000"]$url[/COLOR][/B]/support.html');
Copy linkTweet thisAlerts:
@BezzzZFeb 19.2014 — surreylee you haven't answered anyone yet, have you got this sorted, if so, please post the solution and mark the thread as resolved
×

Success!

Help @surreylee 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.29,
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,
)...