Copy link to clipboard
Copied
Hi,
I know this has been asked previously and I have gone thorugh the posts day after day trying to figure them but am having no luck at all.
Would appreciate someone in the know looking at my code and pointing me in the right direction..
I have an admin section to my site which contains 8 Spry tabs, each one containing a form that I can sue to update my database. I am trying to get the "Submit" button to return me to the tab I was working on but so far either get returnd to the default page or the tabs themselves stop working.. Each seperate tab will have it's own form and so far cannot get even one to work
. Can someone advise please.. code below for my admin page. The code I have inserted relating to the Spry tabs I have placed in bold here ..
Any help will be greatly appreciated..
Regards,
gyesdahl
***************** CODE*************
<?php require_once('../Connections/la.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
$insertSQL = sprintf("INSERT INTO days (name) VALUES (%s)",
GetSQLValueString($_POST['day'], "text"));
//////////// MY INSERT //////////////////////
$tabToShow = 7; // 2 = 3rd tab
//////////////////////////////////////////////
mysql_select_db($database_la, $la);
$Result1 = mysql_query($insertSQL, $la) or die(mysql_error());
$insertGoTo = "admin.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "" : "";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_la, $la);
$query_days = "SELECT days.name FROM days";
$days = mysql_query($query_days, $la) or die(mysql_error());
$row_days = mysql_fetch_assoc($days);
$totalRows_days = mysql_num_rows($days);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/sub.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Untitled Document</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<script src="../SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script>
<script type="text/javascript" src="../SpryAssets/SpryURLUtils.js"></script>
<link href="../SpryAssets/SpryTabbedPanels.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
// Grabs the values of the URL parameters for the current URL.
var params = Spry.Utils.getLocationParamsAsObject();
</script>
<!-- InstanceEndEditable -->
<style type="text/css">
<!--
@Import url("../la.css");
body {
background-color: #000033;
font-family: "Times New Roman", Times, serif;
font-size: 12px;
color: #CC6666;
}
.style1 {font-size: 12px}
.links {color: #CCCC66}
-->
</style>
<link href="backup/styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="65%" height="430" border="3" align="center" bordercolor="#666666" bgcolor="#FFFFFF">
<tr>
<td valign="top"><table width="100%" height="134" border="0" align="center" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<tr>
<td width="523" height="72" align="center" valign="top"><div align="left"><img src="../Images/logo.jpg" width="259" height="72" /></div></td>
<td width="1" height="72"> </td>
<td width="200
" height="72" border="2" bordercolor="#000033"><div align="center"><img src="images/la<?php echo rand(1,10); ?>.jpg" width="159" height="72" /></div></td>
</tr>
<tr align="center" valign="top">
<td height="23" colspan="3" bgcolor="#993300"><div align="center" class="links"><a href="../index.php">Home</a> | About Us | Contact Us | Tours | Air Charter | Managed Properties
<div align="right" style="font-size: 8pt;">
<div align="center"><b><?php echo date("l d M Y"); ?></b></div>
</div>
</div></td>
</tr>
<tr align="center" valign="top">
<th height="17" colspan="3" background="backup/images/sub_feature.jpg"> </th>
</tr>
</table>
<hr align="center" width="100%" size="2" class="brown" />
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left"></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="610" valign="top"><!-- InstanceBeginEditable name="Sub_main" -->
<div id="TabbedPanels1" class="TabbedPanels">
<ul class="TabbedPanelsTabGroup">
<li class="TabbedPanelsTab" tabindex="0">View Tours</li>
<li class="TabbedPanelsTab" tabindex="0">Create Tour</li>
<li class="TabbedPanelsTab" tabindex="0">Delete Tour</li>
<li class="TabbedPanelsTab" tabindex="0">Add Country</li>
<li class="TabbedPanelsTab" tabindex="0">Inclusions</li>
<li class="TabbedPanelsTab" tabindex="0">Exclusions</li>
<li class="TabbedPanelsTab" tabindex="0">Currency</li>
<li class="TabbedPanelsTab" tabindex="0">Days</li>
</ul>
<div class="TabbedPanelsContentGroup">
<div class="TabbedPanelsContent" style="display: none">Content 1</div>
<div class="TabbedPanelsContent" style="display: block">Content 2</div>
<div class="TabbedPanelsContent" style="display: none">Content 3</div>
<div class="TabbedPanelsContent" style="display: none">Content 4</div>
<div class="TabbedPanelsContent" style="display: none">Content 5</div>
<div class="TabbedPanelsContent" style="display: none">Content 6</div>
<div class="TabbedPanelsContent" style="display: none">Content 7</div>
<div class="TabbedPanelsContent" style="display: none">
<form action="admin.php" method="post" name="form2" id="form2">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Day:</td>
<td><p>
<input type="text" name="day" value="" size="32" />
</p>
<p>
<input type="submit" name="button" id="button" value="Submit" />
</p></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form2" />
</form>
<p> </p>
ontent 8</div>
</div>
</div>
<div align="center"></div>
<script type="text/javascript">
HAVE TRIED BOTH OF THE BELOW CODES WITH NO RESULTS. EITHERE RETURNS TO DEFAULT (0) TAB OR THE TABS STOP WORKING
<!--
var TabbedPanels1 = new Spry.Widget.TabbedPanels("TabbedPanels1",{defaultTab:<?php echo($tabToShow);?> });
//-->
</script>
<script type="text/javascript">
<!--
//var TabbedPanels1 = new Spry.Widget.TabbedPanels("TabbedPanels1", {defaultTab:(params.panel ? params.panel :7 )});
//-->
</script>
<!-- InstanceEndEditable --></td>
</tr>
</table>
<p> </p></td>
</tr>
<tr>
<td valign="top"><div align="center" class="style1">Copyright © 2009 Leisure Africa - All Rights Reserved</div></td>
</tr>
</table>
<p> </p>
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result($days);
?>
The Spry URLUtils work only with values passed through the query string. If you are submitting data for insertion into a database, you should be using the POST method.
The simple way to do what you want is to put a hidden field in each of your forms indicating the tab number (counting from 0). For example, put this in the form in the second tab:
<input type="hidden" name="tab" value="1" />
In the PHP at the top of the page, use a conditional statement to find out if $_POST['tab'] exists:
...<?php
if (is
Copy link to clipboard
Copied
The Spry URLUtils work only with values passed through the query string. If you are submitting data for insertion into a database, you should be using the POST method.
The simple way to do what you want is to put a hidden field in each of your forms indicating the tab number (counting from 0). For example, put this in the form in the second tab:
<input type="hidden" name="tab" value="1" />
In the PHP at the top of the page, use a conditional statement to find out if $_POST['tab'] exists:
<?php
if (isset($_POST['tab']) && !empty($_POST['tab'])) {
$tabToShow = $_POST['tab'];
} else {
$tabToShow = 0;
}
?>
Then use the value of $tabToShow to initialize the Spry tabbed panels:
<script type="text/javascript">
<!--
var TabbedPanels1 = new Spry.Widget.TabbedPanels("TabbedPanels1",{defaultTab:<?php echo $tabToShow;?> });
//-->
</script>
Copy link to clipboard
Copied
Hi David,
Many thanks for replying to my post and the time taken. I have tried your advice but my tabs are not working. Seems like everything I try ends up in this state
Have checked the submit format as POST
I added the code and when the page loads the tabs are non-active.. code below with added parts in bold
***** code*****
<?php require_once('../Connections/la.php'); ?>
<?php
if (isset($_POST['tab']) && !empty($_POST['tab'])) {
$tabToShow = $_POST['tab'];
} else {
$tabToShow = 0;
}
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
$insertSQL = sprintf("INSERT INTO days (name) VALUES (%s)",
GetSQLValueString($_POST['day'], "text"));
//////////// MY INSERT //////////////////////
$tabToShow = 7; // 2 = 3rd tab
//////////////////////////////////////////////
mysql_select_db($database_la, $la);
$Result1 = mysql_query($insertSQL, $la) or die(mysql_error());
$insertGoTo = "admin.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "" : "";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_la, $la);
$query_days = "SELECT days.name FROM days";
$days = mysql_query($query_days, $la) or die(mysql_error());
$row_days = mysql_fetch_assoc($days);
$totalRows_days = mysql_num_rows($days);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/sub.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Untitled Document</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<script src="../SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script>
<script type="text/javascript" src="../SpryAssets/SpryURLUtils.js"></script>
<link href="../SpryAssets/SpryTabbedPanels.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
// Grabs the values of the URL parameters for the current URL.
var params = Spry.Utils.getLocationParamsAsObject();
</script>
<!-- InstanceEndEditable -->
<style type="text/css">
<!--
@import url("../la.css");
body {
background-color: #000033;
font-family: "Times New Roman", Times, serif;
font-size: 12px;
color: #CC6666;
}
.style1 {font-size: 12px}
.links {color: #CCCC66}
-->
</style>
<link href="backup/styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="65%" height="430" border="3" align="center" bordercolor="#666666" bgcolor="#FFFFFF">
<tr>
<td valign="top"><table width="100%" height="134" border="0" align="center" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<tr>
<td width="523" height="72" align="center" valign="top"><div align="left"><img src="../Images/logo.jpg" width="259" height="72" /></div></td>
<td width="1" height="72"> </td>
<td width="200
" height="72" border="2" bordercolor="#000033"><div align="center"><img src="images/la<?php echo rand(1,10); ?>.jpg" width="159" height="72" /></div></td>
</tr>
<tr align="center" valign="top">
<td height="23" colspan="3" bgcolor="#993300"><div align="center" class="links"><a href="../index.php">Home</a> | About Us | Contact Us | Tours | Air Charter | Managed Properties
<div align="right" style="font-size: 8pt;">
<div align="center"><b><?php echo date("l d M Y"); ?></b></div>
</div>
</div></td>
</tr>
<tr align="center" valign="top">
<th height="17" colspan="3" background="backup/images/sub_feature.jpg"> </th>
</tr>
</table>
<hr align="center" width="100%" size="2" class="brown" />
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left"></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="610" valign="top"><!-- InstanceBeginEditable name="Sub_main" -->
<div id="TabbedPanels1" class="TabbedPanels">
<ul class="TabbedPanelsTabGroup">
<li class="TabbedPanelsTab" tabindex="0">View Tours</li>
<li class="TabbedPanelsTab" tabindex="0">Create Tour</li>
<li class="TabbedPanelsTab" tabindex="0">Delete Tour</li>
<li class="TabbedPanelsTab" tabindex="0">Add Country</li>
<li class="TabbedPanelsTab" tabindex="0">Inclusions</li>
<li class="TabbedPanelsTab" tabindex="0">Exclusions</li>
<li class="TabbedPanelsTab" tabindex="0">Currency</li>
<li class="TabbedPanelsTab" tabindex="0">Days</li>
</ul>
<div class="TabbedPanelsContentGroup">
<div class="TabbedPanelsContent" style="display: none">Content 1</div>
<div class="TabbedPanelsContent" style="display: block">Content 2</div>
<div class="TabbedPanelsContent" style="display: none">Content 3</div>
<div class="TabbedPanelsContent" style="display: none">Content 4</div>
<div class="TabbedPanelsContent" style="display: none">Content 5</div>
<div class="TabbedPanelsContent" style="display: none">Content 6</div>
<div class="TabbedPanelsContent" style="display: none">Content 7</div>
<div class="TabbedPanelsContent" style="display: none">
<form action="admin.php" method="post" name="form2" id="form2">
<input name="tab" type="hidden" value="7" /> <table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Day:</td>
<td><p>
<input type="text" name="day" value="" size="32" />
</p>
<p>
<input type="submit" name="button" id="button" value="Submit" />
</p></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form2" />
</form>
<p> </p>
ontent 8</div>
</div>
</div>
<div align="center"></div>
<script type="text/javascript">
<!--
<script type="text/javascript">
<!--
var TabbedPanels1 = new Spry.Widget.TabbedPanels("TabbedPanels1",{defaultTab:<?php echo $tabToShow;?> });
//-->
</script>
<!-- InstanceEndEditable --></td>
</tr>
</table>
<p> </p></td>
</tr>
<tr>
<td valign="top"><div align="center" class="style1">Copyright © 2009 Leisure Africa - All Rights Reserved</div></td>
</tr>
</table>
<p> </p>
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result($days);
?>
Copy link to clipboard
Copied
You're still hard-coding the value of $tabToShow here:
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
$insertSQL = sprintf("INSERT INTO days (name) VALUES (%s)",
GetSQLValueString($_POST['day'], "text"));
//////////// MY INSERT //////////////////////
$tabToShow = 7; // 2 = 3rd tab
//////////////////////////////////////////////
However, the reason it's not working is this:
$insertGoTo = "admin.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "" : "";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
By redirecting the page, even though it's being sent back to the same page, all variables are being destroyed. Remove that, and it should work.
Copy link to clipboard
Copied
Still no go David...... Took out the hardcoding and the redirect. the page opens but no default tab opens and although the cursor changes to a hand when placed over the tabs they are not clickable to open. If you donlt find anythign wrong this tie around I think I will try buidl the page from scratch again. I just remarked the redirect as well as the sql statement above it as was receiveing a THE QUERY WAS EMPTY.
I did notice that there was a secong hidden field inserted by dreamweaver... tried removing that as well and no change
***************** code*********
<?php require_once('../Connections/la.php'); ?>
<?php
if (isset($_POST['tab']) && !empty($_POST['tab'])) {
$tabToShow = $_POST['tab'];
} else {
$tabToShow = 0;
}
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
$insertSQL = sprintf("INSERT INTO days (name) VALUES (%s)",
GetSQLValueString($_POST['day'], "text"));
}
// mysql_select_db($database_la, $la);
// $Result1 = mysql_query($insertSQL, $la) or die(mysql_error());
// $insertGoTo = "admin.php";
// if (isset($_SERVER['QUERY_STRING'])) {
// $insertGoTo .= (strpos($insertGoTo, '?')) ? "" : "";
// $insertGoTo .= $_SERVER['QUERY_STRING'];
// }
// header(sprintf("Location: %s", $insertGoTo));
mysql_select_db($database_la, $la);
$query_days = "SELECT days.name FROM days";
$days = mysql_query($query_days, $la) or die(mysql_error());
$row_days = mysql_fetch_assoc($days);
$totalRows_days = mysql_num_rows($days);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/sub.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Untitled Document</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<script src="../SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script>
<script type="text/javascript" src="../SpryAssets/SpryURLUtils.js"></script>
<link href="../SpryAssets/SpryTabbedPanels.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
// Grabs the values of the URL parameters for the current URL.
//var params = Spry.Utils.getLocationParamsAsObject();
</script>
<!-- InstanceEndEditable -->
<style type="text/css">
<!--
@import url("../la.css");
body {
background-color: #000033;
font-family: "Times New Roman", Times, serif;
font-size: 12px;
color: #CC6666;
}
.style1 {font-size: 12px}
.links {color: #CCCC66}
-->
</style>
<link href="backup/styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="65%" height="430" border="3" align="center" bordercolor="#666666" bgcolor="#FFFFFF">
<tr>
<td valign="top"><table width="100%" height="134" border="0" align="center" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<tr>
<td width="523" height="72" align="center" valign="top"><div align="left"><img src="../Images/logo.jpg" width="259" height="72" /></div></td>
<td width="1" height="72"> </td>
<td width="200
" height="72" border="2" bordercolor="#000033"><div align="center"><img src="images/la<?php echo rand(1,10); ?>.jpg" width="159" height="72" /></div></td>
</tr>
<tr align="center" valign="top">
<td height="23" colspan="3" bgcolor="#993300"><div align="center" class="links"><a href="../index.php">Home</a> | About Us | Contact Us | Tours | Air Charter | Managed Properties
<div align="right" style="font-size: 8pt;">
<div align="center"><b><?php echo date("l d M Y"); ?></b></div>
</div>
</div></td>
</tr>
<tr align="center" valign="top">
<th height="17" colspan="3" background="backup/images/sub_feature.jpg"> </th>
</tr>
</table>
<hr align="center" width="100%" size="2" class="brown" />
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left"></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="610" valign="top"><!-- InstanceBeginEditable name="Sub_main" -->
<div id="TabbedPanels1" class="TabbedPanels">
<ul class="TabbedPanelsTabGroup">
<li class="TabbedPanelsTab" tabindex="0">View Tours</li>
<li class="TabbedPanelsTab" tabindex="0">Create Tour</li>
<li class="TabbedPanelsTab" tabindex="0">Delete Tour</li>
<li class="TabbedPanelsTab" tabindex="0">Add Country</li>
<li class="TabbedPanelsTab" tabindex="0">Inclusions</li>
<li class="TabbedPanelsTab" tabindex="0">Exclusions</li>
<li class="TabbedPanelsTab" tabindex="0">Currency</li>
<li class="TabbedPanelsTab" tabindex="0">Days</li>
</ul>
<div class="TabbedPanelsContentGroup">
<div class="TabbedPanelsContent" style="display: none">Content 1</div>
<div class="TabbedPanelsContent" style="display: none">Content 2</div>
<div class="TabbedPanelsContent" style="display: none">Content 3</div>
<div class="TabbedPanelsContent" style="display: none">Content 4</div>
<div class="TabbedPanelsContent" style="display: none">Content 5</div>
<div class="TabbedPanelsContent" style="display: none">Content 6</div>
<div class="TabbedPanelsContent" style="display: none">Content 7</div>
<div class="TabbedPanelsContent" style="display: none">
<form action="admin.php" method="post" name="form2" id="form2">
<input name="tab" type="hidden" value="7" />
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Day:</td>
<td><p>
<input type="text" name="day" value="" size="32" />
</p>
<p>
<input type="submit" name="button" id="button" value="Submit" />
</p></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form2" />
</form>
<p> </p>
ontent 8</div>
</div>
</div>
<div align="center"></div>
<script type="text/javascript">
<!--
<script type="text/javascript">
<!--
var TabbedPanels1 = new Spry.Widget.TabbedPanels("TabbedPanels1",{defaultTab:<?php echo $tabToShow;?> });
//-->
</script>
<!-- InstanceEndEditable --></td>
</tr>
</table>
<p> </p></td>
</tr>
<tr>
<td valign="top"><div align="center" class="style1">Copyright © 2009 Leisure Africa - All Rights Reserved</div></td>
</tr>
</table>
<p> </p>
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result($days);
?>
Copy link to clipboard
Copied
I just remarked the redirect as well as the sql statement above it as was receiveing a THE QUERY WAS EMPTY.
I'm not surprised. You commented out the part that executes the query:
// mysql_select_db($database_la, $la); // $Result1 = mysql_query($insertSQL, $la) or die(mysql_error());
I did notice that there was a secong hidden field inserted by dreamweaver... tried removing that as well and no change
If you remove that, the insert record server behavior won't work.
Copy link to clipboard
Copied
Hi
I think I should redo the page from scratch and use your suggestions and see if that improves things. I have been testing on this page for a while before posting here so there may be some other issues etc as my tabs are still dormant.
Copy link to clipboard
Copied
Hi David,
Many thnaks for your patience. I have re-done a basic page and the tabs now are active and the server behaviour works in that it correctly submits data etc. There is no redirect however the page still returns to tab (0) after submit..
*******CODE****
<?php require_once('../Connections/la.php'); ?>
<?php
if (isset($_POST['tab']) && !empty($_POST['tab'])) {
$tabToShow = $_POST['tab'];
} else {
$tabToShow = 0;
}
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form")) {
$insertSQL = sprintf("INSERT INTO days (name) VALUES (%s)",
GetSQLValueString($_POST['days'], "text"));
mysql_select_db($database_la, $la);
$Result1 = mysql_query($insertSQL, $la) or die(mysql_error());
}
mysql_select_db($database_la, $la);
$query_days = "SELECT * FROM days";
$days = mysql_query($query_days, $la) or die(mysql_error());
$row_days = mysql_fetch_assoc($days);
$totalRows_days = mysql_num_rows($days);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/sub.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Untitled Document</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<script src="../SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script>
<link href="../SpryAssets/SpryTabbedPanels.css" rel="stylesheet" type="text/css" />
<!-- InstanceEndEditable -->
<style type="text/css">
<!--
@import url("../la.css");
body {
background-color: #000033;
font-family: "Times New Roman", Times, serif;
font-size: 12px;
color: #CC6666;
}
.style1 {font-size: 12px}
.links {color: #CCCC66}
-->
</style>
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="65%" height="430" border="3" align="center" bordercolor="#666666" bgcolor="#FFFFFF">
<tr>
<td valign="top"><table width="100%" height="134" border="0" align="center" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<tr>
<td width="523" height="72" align="center" valign="top"><div align="left"><img src="../Images/logo.jpg" width="259" height="72" /></div></td>
<td width="1" height="72"> </td>
<td width="200
" height="72" border="2" bordercolor="#000033"><div align="center"><img src="images/la<?php echo rand(1,10); ?>.jpg" width="159" height="72" /></div></td>
</tr>
<tr align="center" valign="top">
<td height="23" colspan="3" bgcolor="#993300"><div align="center" class="links"><a href="../index.php">Home</a> | About Us | Contact Us | Tours | Air Charter | Managed Properties
<div align="right" style="font-size: 8pt;">
<div align="center"><b><?php echo date("l d M Y"); ?></b></div>
</div>
</div></td>
</tr>
<tr align="center" valign="top">
<th height="17" colspan="3" background="images/sub_feature.jpg"> </th>
</tr>
</table>
<hr align="center" width="100%" size="2" class="brown" />
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left"></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="610" valign="top"><!-- InstanceBeginEditable name="Sub_main" -->
<div id="TabbedPanels1" class="TabbedPanels">
<ul class="TabbedPanelsTabGroup">
<li class="TabbedPanelsTab" tabindex="0">Home</li>
<li class="TabbedPanelsTab" tabindex="1">Days</li>
</ul>
<div class="TabbedPanelsContentGroup">
<div class="TabbedPanelsContent">Content 1</div>
<div class="TabbedPanelsContent">Content 2
<form id="form" name="form" method="POST" action="<?php echo $editFormAction; ?>">
<label>Days
<input type="text" name="days" id="days" />
</label>
<label>
<input type="submit" name="sub1" id="sub1" value="Submit" />
<input type="hidden" name="tab" id="1" />
</label>
<input type="hidden" name="MM_insert" value="form" />
</form>
</div>
</div>
</div>
<script type="text/javascript">
<!--
var TabbedPanels1 = new Spry.Widget.TabbedPanels("TabbedPanels1",{defaultTab:<?php echo $tabToShow;?> });
//-->
</script>
<!-- InstanceEndEditable --></td>
</tr>
</table>
<p> </p></td>
</tr>
<tr>
<td valign="top"><div align="center" class="style1">Copyright © 2009 Leisure Africa - All Rights Reserved</div></td>
</tr>
</table>
<p> </p>
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result($days);
?>
Copy link to clipboard
Copied
Hi David,
It works!!! Found a small error and now tested on two tabs and all fine...
Thanks very much..
Gyesdahl
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more