/    Sign up×
Community /Pin to ProfileBookmark

Login Problem

Hi,
i am trying to redirect page when user name is not valid but its not showing error which i am not able to rectify it,how to redirect it when it found right user else redirect to diff. page

[code=php]
<?
$guestpass = “lightswitch”;
if ($name == “Guest” || “guest”)
{
if ($pw == $guestpass)
{
redirect(index.html);
}
}
else
{
redirect(index1.html)”;
}
?>

[FORM]
<form method=”POST” action=”check.php”>
<div align=”left”><p><font face=”BankGothic Md BT”>Name</font>
<input type=”text” name=”name” size=”14″>
<br>
<div align=”left”><p><font face=”BankGothic Md BT”>Password</font>
<input type=”password” name=”pw” size=”14″><BR><BR><input type=”submit”
value=”Submit”></p>
</div></form>

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@AdamGundryJun 18.2003 — The function redirect() does not exist. Use this instead:

header("Location: index.html");

Adam
Copy linkTweet thisAlerts:
@zuzupusauthorJun 18.2003 — Thanks for reply but unfortunately its not working may be u no the reason please

when i use below code after </form> its not at all working and when i use this code at top of the <form> and when i am trying to open check.php its staightway opening index1.html instead of login and pwd field when user can enter value and then submit.

hope understood

<?

$guestpass = "lightswitch";

if ($name== "guest")

{

if ($pw == $guestpass)

{

header("Location:index.html");

}

}

else

{

header("Location:index1.html");

}

?>
Copy linkTweet thisAlerts:
@AdamGundryJun 18.2003 — Ok, try this:[code=php]<?
if (isset($HTTP_POST_VARS['name'])){
$guestpass = "lightswitch";
if (($HTTP_POST_VARS['name']== "guest") && ($HTTP_POST_VARS['pw'] == $guestpass)){
header("Location:index.html");
} else {
header("Location:index1.html");
}
}
?>[/code]
Adam
Copy linkTweet thisAlerts:
@zuzupusauthorJun 18.2003 — thank you very much its working now ?

instead of using is it possible i can retrieve user directly from database

list($user)= query_db("select user from t_user from intern='t'")

if ($user){

header("Location:index.phtml");

}

else {

header("Location:index1.html");

}

i dont want to use for all users from database like below code

if (isset($HTTP_POST_VARS['account'])){

if (($HTTP_POST_VARS['account']== "admin")){

header("Location:index.html");

}

if (($HTTP_POST_VARS['account']== "admin1")){

header("Location:index.html");

}

if (($HTTP_POST_VARS['account']== "admin2")){

header("Location:index.html");

}

if (($HTTP_POST_VARS['account']== "admin3")){

header("Location:index.html");

}

else {

header("Location:index1.html");

}

}

is therer any solutin so that i can store user in any variable from databse and then redirect it

thanks in advance
Copy linkTweet thisAlerts:
@AdamGundryJun 18.2003 — Here's a script for querying a MySQL database for username and password - you should be able to adapt it.
[code=php]<?
if (isset($HTTP_POST_VARS['submit'])){
mysql_connect("localhost","mysql username","mysql password");
mysql_select_db("database");

$result = mysql_query("select username from table where username='" .
strtolower($HTTP_POST_VARS['username']) . "' and password='" .
md5($HTTP_POST_VARS['password']) . "'") or die("Query failed: " . mysql_error());

if (mysql_num_rows($result) == 1){
header("Location: index.html");
exit;
} else {
header("Location: index1.html");
exit;
}
}
?>[/code]


This table uses MD5 encryption on the password field, so either remove the md5() function or make sure you use md5() when setting the passwords.

Adam
Copy linkTweet thisAlerts:
@zuzupusauthorJun 18.2003 — thanks its appreciated ?
×

Success!

Help @zuzupus 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...