You are here: Re: php ajax redirect « PHP Programming Language « IT news, forums, messages
Re: php ajax redirect

Posted by Mike on 11/27/07 20:25

On Nov 27, 12:52 pm, Toby A Inkster <usenet200...@tobyinkster.co.uk>
wrote:
> 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/

Actually I did get it to work with this:(which of course is just
Javascript)
if (xmlHttp.readyState==4)
{
if (xmlHttp.responseText == "<p>Wrong Username or Password Dufus</
p>")
{
document.getElementById("txtHint").innerHTML=xmlHttp.responseText
}
else window.location = "http://www.ampsoft.com/NCAA/Main_Mockup.php"
}
}

Thanks
Mike

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация