473,467 Members | 1,577 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

php ajax redirect

Hello,
I have a Login page that checks a Db for a Un and Pw using ajax.
If the Login is incorrect, they just get a embedded message.
If it is correct, I want to redirect COMPLETLY.
Whats happening is the new page is being embedded into the login page,
and I dont want that.
.............................
if ($rowcount==0){
echo "<p>Wrong Username or Password Dufus</p>";
}
else
{//echo "<p>Your logged in $result_1[u]</p>";
$_SESSION['U'] = $result_1[u];
$_SESSION['P'] = $result_1[P];
header( 'Location: Main_Mockup.php' );
}
................................

Any suggestions for this
Thanks
Mike
Nov 27 '07 #1
5 3628
On 27 Nov, 14:37, Mike <ampel...@gmail.comwrote:
Hello,
I have a Login page that checks a Db for a Un and Pw using ajax.
If the Login is incorrect, they just get a embedded message.
If it is correct, I want to redirect COMPLETLY.
Whats happening is the new page is being embedded into the login page,
and I dont want that.
............................
if ($rowcount==0){
echo "<p>Wrong Username or Password Dufus</p>";}

else
{//echo "<p>Your logged in $result_1[u]</p>";
$_SESSION['U'] = $result_1[u];
$_SESSION['P'] = $result_1[P];
header( 'Location: Main_Mockup.php' );}

...............................

Any suggestions for this
Thanks
Mike
I think that "Your logged in" should possibly be "You're logged in".

Now for your initial question, it depends on what you are doing on the
client with this returned data. Are you in a frame? Maybe you could
use the href object?
Nov 27 '07 #2
On Nov 27, 9:47 am, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 27 Nov, 14:37, Mike <ampel...@gmail.comwrote:


Hello,
I have a Login page that checks a Db for a Un and Pw using ajax.
If the Login is incorrect, they just get a embedded message.
If it is correct, I want to redirect COMPLETLY.
Whats happening is the new page is being embedded into the login page,
and I dont want that.
............................
if ($rowcount==0){
echo "<p>Wrong Username or Password Dufus</p>";}
else
{//echo "<p>Your logged in $result_1[u]</p>";
$_SESSION['U'] = $result_1[u];
$_SESSION['P'] = $result_1[P];
header( 'Location: Main_Mockup.php' );}
...............................
Any suggestions for this
Thanks
Mike

I think that "Your logged in" should possibly be "You're logged in".

Now for your initial question, it depends on what you are doing on the
client with this returned data. Are you in a frame? Maybe you could
use the href object?- Hide quoted text -

- Show quoted text -
Thank,:)
I dont proofread till the end
I am not in a frame (yuk).
I just want to redirect out to a new page and keep my _session
Variables (Which it does anyway).
I'm pretty good with php, but new at AJAX.
Thanks,
Mike
Nov 27 '07 #3
On 27 Nov, 15:01, Mike <ampel...@gmail.comwrote:
On Nov 27, 9:47 am, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 27 Nov, 14:37, Mike <ampel...@gmail.comwrote:
Hello,
I have a Login page that checks a Db for a Un and Pw using ajax.
If the Login is incorrect, they just get a embedded message.
If it is correct, I want to redirect COMPLETLY.
Whats happening is the new page is being embedded into the login page,
and I dont want that.
............................
if ($rowcount==0){
echo "<p>Wrong Username or Password Dufus</p>";}
else
{//echo "<p>Your logged in $result_1[u]</p>";
$_SESSION['U'] = $result_1[u];
$_SESSION['P'] = $result_1[P];
header( 'Location: Main_Mockup.php' );}
...............................
Any suggestions for this
Thanks
Mike
I think that "Your logged in" should possibly be "You're logged in".
Now for your initial question, it depends on what you are doing on the
client with this returned data. Are you in a frame? Maybe you could
use the href object?- Hide quoted text -
- Show quoted text -

Thank,:)
I dont proofread till the end
I am not in a frame (yuk).
I just want to redirect out to a new page and keep my _session
Variables (Which it does anyway).
I'm pretty good with php, but new at AJAX.
Thanks,
Mike
What I was trying to point out is that you have shown us nothing about
what you are doing on the client, so it is dificult to advise what you
should do differently.
Nov 27 '07 #4
Mike <am******@gmail.comwrote in news:57b383e9-bcbb-4332-98b2-
94**********@x69g2000hsx.googlegroups.com:
On Nov 27, 9:47 am, Captain Paralytic <paul_laut...@yahoo.comwrote:
>On 27 Nov, 14:37, Mike <ampel...@gmail.comwrote:


Hello,
I have a Login page that checks a Db for a Un and Pw using ajax.
If the Login is incorrect, they just get a embedded message.
If it is correct, I want to redirect COMPLETLY.
Whats happening is the new page is being embedded into the login
page,
and I dont want that.
............................
if ($rowcount==0){
echo "<p>Wrong Username or Password Dufus</p>";}
else
{//echo "<p>Your logged in $result_1[u]</p>";
$_SESSION['U'] = $result_1[u];
$_SESSION['P'] = $result_1[P];
header( 'Location: Main_Mockup.php' );}
...............................
Any suggestions for this
Thanks
Mike

I think that "Your logged in" should possibly be "You're logged in".

Now for your initial question, it depends on what you are doing on
the
>client with this returned data. Are you in a frame? Maybe you could
use the href object?- Hide quoted text -

- Show quoted text -

Thank,:)
I dont proofread till the end
I am not in a frame (yuk).
I just want to redirect out to a new page and keep my _session
Variables (Which it does anyway).
I'm pretty good with php, but new at AJAX.
Thanks,
Mike
You're going to have to get pretty familiar with javascript.
Essentially this is a javascript question. You get a result BACK from a
PHP script, and then use javascript to put your result into action.

Perhaps AJAX and login pages don't go together too well - I know in my
apps, I've elected to use a complete form submission.
Nov 27 '07 #5
Mike wrote:
If the Login is incorrect, they just get a embedded message.
If it is correct, I want to redirect COMPLETLY.
if ($rowcount==0)
{
echo "<p>Wrong Username or Password Dufus</p>";
}
else
{
$_SESSION['U'] = $result_1[u];
$_SESSION['P'] = $result_1[P];
print 'Location: Main_Mockup.php';
}

And then your Javascript needs to do something like this:

var $result = (result from AJAX request as string);
if ($result.match( /^Location\:/i ))
{
var $url = $result.replace( /^Location\:\s+/i, '' );
window.location.href = $url;
}
else
{
// Display the message like you already do.
}

The redirection is the Javascript's job here, not PHP's. The PHP just
needs to tell the Javascript where to redirect to.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 3 days, 34 min.]

It'll be in the Last Place You Look
http://tobyinkster.co.uk/blog/2007/11/21/no2id/
Nov 27 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Grzegorz Smith | last post by:
Hi everyone. Does anyone know is it possible to check if ajax call was redirect? i mean I connect by Ajax to one URL but I'm redirected to other url. Is there a way to check that my request was...
7
by: ses | last post by:
How do i implement server side redirect when the request was submitted using AJAX?
1
kamill
by: kamill | last post by:
I am strange for Ajax and i need to redirect a page threw Ajax like Java script(window.location.href="desiredlocation.php". Is there any script in Ajax. Thanking in advance kamill
1
by: kmithu | last post by:
I am working on Asp.Net2.0 on which i have used ajax. I am well aware that Response.Write() is not supported by AJAX but what about Response.Redirect()? The error which i am getting is written...
56
by: UKuser | last post by:
Hi, I'm not sure if this can be done as I've searched the web and this forum. I am using an online merchant provider and I must post certain variables to their webforms through a form on my...
2
by: Angel666 | last post by:
We are using forms authenication with AJAX update control panels. We get various results but no redirect when the user has timed out and is no longer authenicated and does a asyncpostback. We...
1
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi. Is it possible to display an UpdateProgress control when an event calling Response.Redirect is executed? I have a simple webform with an ImageButton and an UpdateProgress control. My...
2
by: Norm | last post by:
The error that pops up in a JS alert box is: Sys.WebForms.PageRequestManagerParserErrorException: The message from the server could not be parsed. ... "<DOCTYPE ..." I have three update panels...
1
by: Yan | last post by:
Hi, I'm apparently far from being the 1st one to meet this error... My asp.net ajax page requires ScriptManager.axd but gets a 404. following a lot of "This is how I solved it" posts, I : -...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.