简体   繁体   中英

Redirect to a different tab page

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM