473,320 Members | 2,117 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Redirect to other page in same domain

32
Hi Friends,

iam newbie,This is my form Authentication script.i need to redirect another page when user correctly authenticated.how to redirect anothe rpage?

[PHP]
<?php
// Include the database connection file.
include("db.php");
// Check if a person has clicked on submit.
if(isset($_POST['submit'])) {
// Create variables from each $_POST.
$uname = $_POST['uname'];
$pwd = $_POST['pwd'];
$cpwd = $_POST['cpwd'];
$email = $_POST['email'];
$city = $_POST['city'];
$state = $_POST['state'];
$que = $_POST['que'];
$ans = $_POST['ans'];

}
// Now, compare passwords and check if they're the same.

if($pwd != $cpwd) {
// If the passwords are NOT the same. Again display an error message and redirect.
echo "Sorry, wrong password.";
exit;
}
// Secure the password using an md5 hash.
$pwd = md5($pwd);

// Create a variable containing the SQL query.
$query = "INSERT INTO `registration` (uname, pwd, email, city, state, que, ans)
VALUES ('$uname', '$pwd', '$email', '$city','$state', '$que', '$ans')";
// Perform the SQL query on the database.
$result = mysql_query($query);
// If the query failed, display an error.
if(!$result) {
// The dot seperates PHP code and plain text.
echo "Your query failed. " . mysql_error();
} else {
// Display a success message!
echo "Welcome " . $uname . " You are now registered";
}
}
?>[/PHP]
May 28 '08 #1
4 1800
rpnew
188 100+
Hi Friends,

iam newbie,This is my form Authentication script.i need to redirect another page when user correctly authenticated.how to redirect anothe rpage?

[PHP]
<?php
// Include the database connection file.
include("db.php");
// Check if a person has clicked on submit.
if(isset($_POST['submit'])) {
// Create variables from each $_POST.
$uname = $_POST['uname'];
$pwd = $_POST['pwd'];
$cpwd = $_POST['cpwd'];
$email = $_POST['email'];
$city = $_POST['city'];
$state = $_POST['state'];
$que = $_POST['que'];
$ans = $_POST['ans'];

}
// Now, compare passwords and check if they're the same.

if($pwd != $cpwd) {
// If the passwords are NOT the same. Again display an error message and redirect.
echo "Sorry, wrong password.";
exit;
}
// Secure the password using an md5 hash.
$pwd = md5($pwd);

// Create a variable containing the SQL query.
$query = "INSERT INTO `registration` (uname, pwd, email, city, state, que, ans)
VALUES ('$uname', '$pwd', '$email', '$city','$state', '$que', '$ans')";
// Perform the SQL query on the database.
$result = mysql_query($query);
// If the query failed, display an error.
if(!$result) {
// The dot seperates PHP code and plain text.
echo "Your query failed. " . mysql_error();
} else {
// Display a success message!
echo "Welcome " . $uname . " You are now registered";
}
}
?>[/PHP]
Hi,
You can do it as follow....

[PHP]
header( 'Location: url_where_you_want_to_redirect') ;
[/PHP]

Regards,
RP
May 28 '08 #2
TheServant
1,168 Expert 1GB
Hi,
You can do it as follow....

[PHP]
header( 'Location: url_where_you_want_to_redirect') ;
[/PHP]

Regards,
RP
Just make sure there is no html output before that, otherwise it will come out with an error saying headers already sent.
May 28 '08 #3
rpnew
188 100+
Just make sure there is no html output before that, otherwise it will come out with an error saying headers already sent.
Ahh... thanks for correction i forgot to mention that...

Regards,
RP
May 29 '08 #4
TheServant
1,168 Expert 1GB
Ahh... thanks for correction i forgot to mention that...

Regards,
RP
Yeah, the only problem with using headers(). It always gets asked.
May 29 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Damo | last post by:
Could someone please help me. I am a newbie at PHP. I downloaded formail.php Version 5.0 from Jacks scripts( http://www.dtheatre.com/scripts/ )and changed the required areas to my email address and...
2
by: Robert Gordon | last post by:
I now realize I probably should have tried posting this on the IIS board first.. I am running OWA 2003 Server as Front End server to my Exchange 2000 native domain. The FE server is secured by...
3
by: Hans | last post by:
Hi there, I have a number of domain names and they all point to the same IP address. I would like to redirect to a specific folder, based on the domain name used to access the site. For example....
3
by: Mr B | last post by:
Howdy all, I have 2 domain names that both go to the same website. For example, if www.XXXX.com is the primary name for the website, if you type in www.XXXX.com or www.YYYY.com, they both go...
11
by: Vic Spainhower | last post by:
Hello, I just purchased a new domain name and I've set it up as a redirect to a folder on my main site. What is happening is the index.php page checks a session variable to see if the user is...
1
by: Lionel | last post by:
Hi, I've a VB .Net web app (for example foo) on an internal server. In the intranet we can access this application like this : http://myserver/foo/index.aspx. Now we want to make this...
1
by: Alan Silver | last post by:
Hello, I have a page where site owners can see orders placed on their site. The path to this page is /dap/order.aspx, but for security reasons (as they will end up printing these pages and...
7
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I am trying to set this up using asp code and IIS configuration. But it seems not working. Here it is the way I am doing. In IIS I set up a virtual directory with secure communication, I...
9
by: RN1 | last post by:
When a server encounters the line Response.Redirect("abcd.asp") in a ASP script, the server tells the browser that it has to be redirected to another page (which is abcd.asp, in this case)....
6
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, We have two sites hosted on different servers and we have many pages on domain A which has many links(asp programs) to domain B. My question is if domain B server is in trouble, what is...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.