ScottInTexas
05-28-2007, 03:56 PM
I have my web site set up in a typical 2 column/header format. The left column being the location for a menu and other items. The right column carrying the content of the selected page. When I call index.php I have a check to see if the $_POST['submit'] was fired take the appropriate action by using an invisable field within any form the user might be filling out and in my menu so that everytime index is called I can check the menuaction and use a switch to perform the action.
if (isset($_POST['submit']))
switch ($_POST['menuaction']){
case 'login':
{
$SESSION['UserName']=$_POST['UserID'];
$SESSION['pswd']=md5($_POST['Password']);
break;
}
case 'urlrequest':
{
$thisPage=$POST['menuItem'];
break;
}
default:
$thisPage="Home";
}
So in the above case the third variable passed with $_POST would be "login" and the user would be set in the session. In another case it maybe "WriteMe" and the session set wouldn't go but the index.php would make the "Content" another form for contacting me.
For the login form I don't have a problem since it is a plain form. But, for the menu, I have to use javascript to insert a value into a hidden form field and then fire submit with code. But I put an onclick="menuOps" in the page and it's not calling it. I tried it in the <li tag and the <a tag. Then I have to set the hidden field and I can't seem to make that work either.
<script language="Javascript" type="text/javascript">
<!--
function menuops(choice){
var rqstPage;
var subbtn;
var frmField;
alert "Menuops called with " + choice;
frmField=document.getElementByID("menuForm");
frmField.menuaction.value=choice;
menuForm.submit;
}
//-->
</script>
<div id="menu">
<ul>
<li<?php if ($thisPage=="Home")
echo " id=\"currentpage\""; ?>>
<a href="#" onclick="menuops('Home')">Home</a></li>
<li<?php if ($thisPage=="Page Two")
echo " id=\"currentpage\""; ?>>
<a href="#">Services</a></li>
<li<?php if ($thisPage=="Page Three")
echo " id=\"currentpage\""; ?>>
<a href="#">Place Order</a></li>
<li<?php if ($thisPage=="Page Four")
echo " id=\"currentpage\""; ?>>
<a href="#">Contact Us</a></li>
</ul>
</div>
<div id="menuFormDiv" visible="false">
<form id="menuForm">
<input type="hidden" name="menuaction">
<input type="submit" value="" name="submit">
</form>
</div>
Sorry for the lengthy post but I wanted you to have everything you needed to make an informed response.
Do you see a better way? Or can you point out my obvious errors?
if (isset($_POST['submit']))
switch ($_POST['menuaction']){
case 'login':
{
$SESSION['UserName']=$_POST['UserID'];
$SESSION['pswd']=md5($_POST['Password']);
break;
}
case 'urlrequest':
{
$thisPage=$POST['menuItem'];
break;
}
default:
$thisPage="Home";
}
So in the above case the third variable passed with $_POST would be "login" and the user would be set in the session. In another case it maybe "WriteMe" and the session set wouldn't go but the index.php would make the "Content" another form for contacting me.
For the login form I don't have a problem since it is a plain form. But, for the menu, I have to use javascript to insert a value into a hidden form field and then fire submit with code. But I put an onclick="menuOps" in the page and it's not calling it. I tried it in the <li tag and the <a tag. Then I have to set the hidden field and I can't seem to make that work either.
<script language="Javascript" type="text/javascript">
<!--
function menuops(choice){
var rqstPage;
var subbtn;
var frmField;
alert "Menuops called with " + choice;
frmField=document.getElementByID("menuForm");
frmField.menuaction.value=choice;
menuForm.submit;
}
//-->
</script>
<div id="menu">
<ul>
<li<?php if ($thisPage=="Home")
echo " id=\"currentpage\""; ?>>
<a href="#" onclick="menuops('Home')">Home</a></li>
<li<?php if ($thisPage=="Page Two")
echo " id=\"currentpage\""; ?>>
<a href="#">Services</a></li>
<li<?php if ($thisPage=="Page Three")
echo " id=\"currentpage\""; ?>>
<a href="#">Place Order</a></li>
<li<?php if ($thisPage=="Page Four")
echo " id=\"currentpage\""; ?>>
<a href="#">Contact Us</a></li>
</ul>
</div>
<div id="menuFormDiv" visible="false">
<form id="menuForm">
<input type="hidden" name="menuaction">
<input type="submit" value="" name="submit">
</form>
</div>
Sorry for the lengthy post but I wanted you to have everything you needed to make an informed response.
Do you see a better way? Or can you point out my obvious errors?