redirect to specific nav-pill

Good morning & Happy New Year.
I am fairly new to PHP and am having issue.
The issue is trying to redirect back to current page to a specific nav-pill after adding a new record to the associated MYSQL table. My nav-pills are defined as follows:

After posting a new receipt I would like to redirect back to #pReceipts pill to show the new entry. I think I need some js to handle the redirect but can’t seem to get it. The current redirect command is

		if($result && mysqli_affected_rows($con) == 1){
			$session->msg('s',"Receipt Added ");
			redirect('edit_project.php?id='.$project['id'], false);
		} else {
			if (!$err_num) {
				$session->msg('d',' Error adding receipt!');
				redirect('edit_project.php?id='.$project['id'], false);
			} else {	 
				$session->msg('d',' Error adding receipt!');
				redirect('edit_project.php?id='.$project['id'], false);
			}
		}   

This works but always show the active defined nav-pill. Not sure how to redirect to a specific nav-pill. Are there any good examples to accomplish the desired effect? Trying to to refresh or redirect to the currently displayed view.

Rod

I dont know what this redirect is you have. It should be header with Location. You have not shown how you have the bookmark setup. If this doesnt work, your bookmarks are not done correctly.

Bookmarks are simple.

Bookmark Link:
Jump to Chapter 4

Bookmark Target:

Chapter 4

[php] die(header(“Location: edit_project.php?id={$project[‘id’]}#bookmark”));[/php]

My bookmark is defined as follows:

<div id="pReceipts" class="tab-pane fade">

followed by the associated form.

Attached is the file - text of php


edit_project - Copy.txt (14.5 KB)

Also, there is no such thing as a redirect() function in PHP. Although, I may be wrong. To redirect a page to
another page, either use header(“Location: somepage”) or use http_redirect() function. I suspect you did
mean to use the latter. If so, this line in your post:
redirect(‘edit_project.php?id=’.$project[‘id’], false);
would need to be:
http_redirect(‘edit_project.php?id=’.$project[‘id’], false);

Here is the link to it’s details…
http://php.net/manual/en/function.http-redirect.php
But, most programmers use the header() function instead. It is here:
http://php.net/manual/en/function.header.php

These two work differently depending on what you need…

My redirect function is in my library and defined as:

function redirect($url, $permanent = false)
{
if (headers_sent() === false)
{
header('Location: ’ . $url, true, ($permanent === true) ? 301 : 302);
}

exit();

}

From what I am reading I need to dynamically define the class as active while removing the current active navigation item.

Any ideas where I can learn more about creating that process.

I have tested the dynamic nav-pill control and it appears to be working properly. When each is clicked the proper panel is displayed. I have compared it to the Bootstrap example of Toggable / Dynamic Pills. Not sure what is the problem.

The tabs are not standard bookmarks. Add this Java-script to your page, then doing a normal bookmark URL as previously talked about will work.

[php][/php]

Complete working demo:

[code]





Home
Profile
Messages
Settings

* Links must be copy/pasted to address bar. Will not work clicking here.
Home Link From Outside
Profile Link From Outside
Messages Link From Outside
Settings Link From Outside

[/code]

Thanks Kevin, I just got back and will be checking this out. Will run the code then try some of my scenarios. I am sure I will definitely learn from this. Thanks again. Will reply again tomorrow after testing.

Rod

Sponsor our Newsletter | Privacy Policy | Terms of Service