php ajax redirect

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike

    #1

    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
  • Captain Paralytic

    #2
    Re: php ajax redirect

    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?

    Comment

    • Mike

      #3
      Re: php ajax redirect

      On Nov 27, 9:47 am, Captain Paralytic <paul_laut...@y ahoo.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

      Comment

      • Captain Paralytic

        #4
        Re: php ajax redirect

        On 27 Nov, 15:01, Mike <ampel...@gmail .comwrote:
        On Nov 27, 9:47 am, Captain Paralytic <paul_laut...@y ahoo.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.

        Comment

        • Good Man

          #5
          Re: php ajax redirect

          Mike <ampeloso@gmail .comwrote in news:57b383e9-bcbb-4332-98b2-
          943467baca8c@x6 9g2000hsx.googl egroups.com:
          On Nov 27, 9:47 am, Captain Paralytic <paul_laut...@y ahoo.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.


          Comment

          • Toby A Inkster

            #6
            Re: php ajax redirect

            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

            Comment

            Working...