Is there any way to do this in PHP (or with a combination of

There's a login form on page A: http://www.example.com/A.html

The 'action' attribute of which is: action="/B.html"

So when someone logs in with the form on A.html, the data will be submitted to / visitor redirected to B.html.

Now what I want is: there's an on /C.html, framing B.html, is there any way so that when someone logs in with the form on A.html, the visitor is redirected to C.html and the login details is submitted to B.html that's framed on C.html in the ? So after the person logs in from A.html, he arrives at C.html with the actual CP dashboard framed in an

2 Replies

This has little to do with PHP or any other server-side programming.

1) Avoid iframes like the plague.

2) Ever heard of the fancy word, AJAX? It's javascript, and it will do approximately what you want (and more).

3) If you want it quick and dirty:

  • Submit your form to B.html / B.php / whatever.

  • Make B.html redirect the client immediately to C.html. This can be done with an HTML header, a PHP function header('Location="…"), or by javascript window.location = "…";

  • In C.html,

  • In order to prevent an infinite loop, you'll need to tell B.html NOT to redirect again if it finds itself inside an iframe.

And of course, it's up to you to make sure that the whole thing is secure.

The whole design is wrong to begin with. Here are some guidelines:

1. Separate form processors in individual .php files, those should only and always redirect upon success and accept only POST.

2. If you need to track login data in an iframe (or with AJAX), have a separate script that reads such info from session or database. Naturally, have the login form processor put any relevant data into the session.

BTW, never redirect with meta tags or javascript, HTTP has redirection functionality with Locatio nheader and 302 or 303 (preferred for POST form processors redirecting to a GET) response codes. Check php.net/header for more info.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct