Forum Moderators: coopster
I'm developing a custom-based inventory/clients/orders desktop application in php. Because of the nature of these kind of applications being desktop, i currently have many problems programming the whole thing to act like a desktop one. One of my problems is the following:
I have a form which submits data to a process.php. The process.php listens for a hidden post variable so it can know which form is being processed. Everything goes fine - the correct method is called but here is where the problem comes.
After sucessfull run of the mysql queries, the user must be redirected to a success page. I have used header in doing that and it works perfect. The only problem i have is that the page that the user is being redirected opens in a NEW TAB on firefox. How can i do it so it will open in the same tab ?
Best Regards,
thanasisdev
I am also making the assumption that you are using the traditional client server model, albeit you are running both on the same machine.
From the manual:
Note: HTTP/1.1 requires an absolute URI as argument to » Location: including the scheme, hostname and absolute path, but some clients accept relative URIs. You can usually use $_SERVER['HTTP_HOST'], $_SERVER['PHP_SELF'] and dirname() to make an absolute URI from a relative one yourself:
<?php
/* Redirect to a different page in the current directory that was requested */
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra = 'mypage.php';
header("Location: http://$host$uri/$extra");
exit;
?>
As if you can do it through ajax then you should be able to do it through the more traditional approach...seeing as they are both http requests.
Thanks all for your replies.
I'm using a VMWARE virtual machine for the application.
My local machine listens on 0.3 and the VMWARE (the application) listens on 0.11.
I tried supplying the full path as parameter to the header but it does not work. It still redirects me to the page that i want but it opens the page with a new tab.
Is there a way to achieve this kind of functionality by using the header() or should i look somewhere else ? (ajax request maybe?)
Best Regards,
A.Emmanouilidis
While ajax would sort your problem, it is not really a solution. As it is just covering up the issue.
There is something different about this use of header. Exactly what that is I cant say. You need to look through all of your code to try and find that difference.
Is everything done over http or https, are you mixing protocols?
I would expect an anchor with the target="_blank" attribute to open a link in another tab/window, however these dont involve the header function. So I am obviously missing something.
You may need to post some larger chunks of code. Maybe both those where it is working correctly and where it isnt.
I have a form which submits data to a process.php. ....
I would expect an anchor with the target="_blank" attribute to open a link in another tab/window...
Or
target="anything"on your FORM element?
As far as I'm aware there is nothing that can be sent back from the server (ie. from PHP) that could trigger the browser to open a new tab / window. This sounds like a client-side issue... either an HTML target attribute or possibly JavaScript. Try disabling JS (easy to do in FF) to rule out the JS.
I just can't figure out a solution. I have tried almost everything that i could think.
I tested the page in Internet Explorer and it opens the page in a new window!
I disabled the javascript in the Firefox and same behaviour happens ! The page is loaded in a new tab !
Really, i have run out of ideas. Help into this matter will be highly appreciated !