1

I have a single page index.php with 2 tab button to separated each content. Everytime user click on this tab button they will see different content.


<ul>
<li>
<a href="javascript:changeTab('dns_soa','dns/dns_soa_edit.php')">DNS Zone</a>
</li>
li class="active"> // current active page
<a href="javascript:changeTab('dns_records','dns/dns_soa_edit.php')">Records</a>
</li> 
</ul>


I need to directly redirect to 'dns_records' tab with header redirect after processing form without clicking the tab:

header("Location: /dns/dns_soa_edit.php?id=$zone");

How can I do that? Thank you.

sg552
  • 1,521
  • 6
  • 32
  • 59

1 Answers1

0

In the same file that processes the form, you can use this up the top.

<?php
    if ( isset($_POST['zone_id']) ) {
        $zone_id = $_POST['zone_id'];
        header("Location: /dns/dns_soa_edit.php?id={$zone_id}");
    }
?>

This assumes that the form has a field with id zone_id when using the POST method and the target is either left blank in HTML5 specifying the same page, or is set to the name of the same php file. You can just echo basename(__FILE__) to get the name of the current php file. In the file dns_soa_edit.php (which may be the same file that contains the code above), you would read in $_GET[$zone_id] in the same manner and load the details from there.

Aram Kocharyan
  • 20,165
  • 11
  • 81
  • 96
  • I'm sorry I still could not understand you. I know how to redirect with headers but I didn't know how to land the user directly to a active tab page. I still not sure how to redirect user to `('dns_records','dns/dns_soa_edit.php')` – sg552 Feb 07 '12 at 16:34
  • I fear I misunderstood you as well. Do you refer to tabs as the browser tabs or tabs in your application? – Aram Kocharyan Feb 07 '12 at 19:21
  • Tab in my website. I put a demo here: `http://cheapantivirus.me/update.php`. The tab menu didn't work but don't worry because it's works in live site. I just need to redirect user to active tab which is `Records`. – sg552 Feb 08 '12 at 05:36
  • You can read POST or GET with javascript, and then invoke `changeTab('dns_records','dns/dns_soa_edit.php')` from the script in the header, will that do? – Aram Kocharyan Feb 08 '12 at 07:49
  • Correction, you can only access GET variables, but that shouldn't be a problem I think. http://stackoverflow.com/questions/1961069/getting-value-get-or-post-variable-using-javascript – Aram Kocharyan Feb 08 '12 at 07:51
  • 1
    The problem has been solved. I appreciate your help :) Solution: http://stackoverflow.com/questions/9258126/redirect-with-button – sg552 Feb 13 '12 at 16:26