|
|
|
|
|
|
| |
I created an Access database which the customer wanted to access from the web. What's more, they wanted the web version to look exactly like the Access version - so they wanted to click buttons rather than links to pages. I created an index page that presented buttons and used the Header function to decide where to go. It looks like this:
Buffer the page becuse if ANYTHING is output to the browser before the relocation - it wont work This is at the very top of the .php file.
| <?php
ob_start();
// Check whether we are returning from a button-press
// The HTML Form Buttons are simply called Opt1, Opt2 ...Optn
// Set $opt to zero
$opt = 0;
// Check which (of 6) buttons clicked (if any)
if(isset($opt1)) $opt=1;
if(isset($opt2)) $opt=2;
if(isset($opt3)) $opt=3;
if(isset($opt4)) $opt=4;
if(isset($opt5)) $opt=5;
if(isset($opt6)) $opt=6;
//If $opt is NOT still zero (a button was clicked), determine which one...and go there.
if($opt)
{
switch ($opt) {
case 1 :
header("Location: http://www.yourpage.php?var1=$var1&var2=$var2);
exit;
case 2 :
header("Location: http://www.yourpage2.php?var1=$var1&var2=$var2);
exit;
case 3 :
header("Location: http://www.yourpage3.php?var1=$var1&var2=$var2);
exit;
case 4 :
header("Location: http://www.yourpage4.php?var1=$var1);
exit;
case 5 :
// Cases 5 & 6 included for future expansion
break;
case 6 :
break;
}
exit;
}
// If $opt is still Zero - no button has been pressed
// so your visitor has just arrived or clicked refresh
// or back.
else
{
?>
// Finish off the php and start the HTML (where the buttons are presented in an ordinary HTML form [they are ALL Submit buttons].)
<html>
<head>
| |
...
etc.
This has several advantages. No links, just buttons. One index page allows parameters to be set (using check boxes etc) before choosing a page to go to, which negates the need to quiz the visitor for variables when (s)he gets there.
|
|
| Record Set Paging with PHP (RSP) Categories : PHP, MySQL, Navigation, Databases, HTML and PHP | | | GonxTabs : Create elegant HTML tabs based interface Categories : Navigation, HTML, HTML and PHP, PHP | | | Database resultset navigation Categories : PHP, HTML and PHP, Databases, MySQL, Navigation | | | TreeView - Finally a working tree view function to be used as you want. Simple create the Table using the code provided and you will be able to have a tree view in your project. Download the zip to get the images. Categories : PHP, HTML and PHP, Navigation | | | PHP3: Formmail. Just a cgi formmail, but than in PHP. It is easy to use! Categories : HTML and PHP, Email, PHP, Perl, HTML and PHP | | | A simple class with some HTML output functions that would come in handy for consistent page layout etc. Categories : PHP, PHP Classes, HTML and PHP, HTML, Navigation | | | a function that builds an HTML select list from any mysql table. Categories : PHP, MySQL, HTML and PHP | | | Tag content retrieval from websites with preg_match Categories : PHP, Regexps, Arrays, HTML and PHP | | | Message of the Day - Random Message (Needs MySQL!) Categories : Databases, HTML and PHP, PHP, MySQL | | | Check parameters validity. Paranoia was designed to check the validity of the parameters that a php page will receive after a form submission. It can be used to check the variables sent by POST or GET Categories : Algorithms, HTML and PHP, PHP, Variables | | | Alternating background color for HTML table rows Categories : PHP, Databases, MySQL, HTML and PHP | | | Constantly refresh your PHP/HTML page data. Categories : PHP, HTML and PHP, Sybase | | | background music script for random notes in a frame Categories : PHP, Content Management, HTML and PHP | | | A very simple way to build and do a hierarchical html categories browser without javascript , just using html php and mySql
Categories : HTML and PHP, Databases, Algorithms, PHP, MySQL | | | Random Image Display Categories : PHP, Filesystem, Graphics, HTML and PHP | |
| | | | Jon Slack wrote : 1068
I should perhaps have mentioned that the action= part of the form declaration is PHP_SELF or the URL of this index page so that upon pressing any of the 6 submit buttons always beings the visitor back to the same page.
:o)
| | | | matthew waygood wrote :1069
Your example is a bit half-hearted. It doesnt contain full code as an example should. It just looks like an example of a switch statement. There is no reference to $_GET to process the passed values or how you are showing the buttons.
Surely a simpler example would be to replace all links with forms.
function link_as_button($url, $link)
{
return `<form method="get" action="`.$url.`"><input type="submit" value="`.$link.`"/></form>`;
}
To use it just supply the URL and the Text for the button.
echo link_as_button("index.php", "home");
| |
|
|
|