Having problems using the "switch" statement

Hi guys i have switch statement that calls to .php pages but for some reason it doesn’t , the pages are not displayed. help !
Below is the attachment whole script of my admin home page.

[code]<?php
error_reporting(1);
session_start();
$name=$_SESSION[‘eid’];
if($_REQUEST[‘log’]==‘out’)
{
session_destroy();
header(“location:index.php”);
}
else if($name=="")
{
header(“location:index.php”);
}
?>

a{text-decoration:none} a:hover{background-color:#FFFFFF}
	    <h5>&nbsp;</h5>
	    <input type="text" name="t1" value="search" onfocus=

"if(this.value==‘search’)
{this.value=’’;}
"
onBlur=
"if(this.value==’’)
{this.value=‘search’;}
"/>

	  <h5>&nbsp;</h5>
	  <!--</form>-->
	

	<!-- End of Page Search -->
</div>




Home     LogOut


Add Item

<a href="?con=view"><font color="#660066" size="+2">View All</font>
</a><br/><br/>
 <a href="?con=ord"><font color="#660066" size="+2">Orders(
 <?php

include(“config.php”);
$rows_returned=0;
$sql= ‘SELECT * FROM my-first’;
$rs=$db_connect->query($sql);
if($rs === false) {
trigger_error('Wrong SQL: ’ . $sql . ’ Error: ’ . $db_connect->error, E_USER_ERROR);
} else {
$rows_returned = $rs->num_rows;
}

 ?>)</font>
</a>
<br/><br/>
 <a href="?con=fdbk"><font color="#660066" size="+2">Feedback(
 <?php
 include("config.php");

$rows_returned=0;
$sql=‘SELECT * FROM My -second’;
$rs=$db_connect->query($sql);

if($rs === false) {
trigger_error('Wrong SQL: ’ . $sql . ’ Error: ’ . $db_connect->error, E_USER_ERROR);
} else {
$rows_returned = $rs->num_rows;
}
echo $rows_returned;
?>)

</div>
<?php switch($_REQUEST['con']) { case 'add':include("addanitem.php"); break;

case ‘view’:include(“viewanitem.php”);
break;
case ‘ord’:include(“orders.php”);
break;
case ‘fdbk’:include(“fdbk.php”);
break;
case ‘hm’:include(“hm.php”);
break;
}
if($_REQUEST[‘view’])
{
include(“viewtable.php”);
}

	?>
[/code]

Thanxs guys


admin_home.txt (2.82 KB)

Well, Kelvine, your way to set the variable $con is a bit odd, but should work in theory. But, you do not tell
your form’s submit button to go anywhere. And, you use form fields, but, never set up a form. Therefore, I
think your form will never post anything. But, since you are using links to post your invisible form back to the
page, you most likely need to use $_GET[‘con’] not $_REQUEST[‘con’]… Try that and see what you get back.

One note on debugging this… You can use this line: print_r($_REQUEST); to display all of the items inside
the REQUEST array. In that way, you can follow what is being sent back to the page. To explain a bit further,
$_REQUEST is a combination of $_POST, $_GET and $_COOKIE arrays. If you print it, you can see it’s layout
and figure out how to locate the ‘con’ part. But, I would guess use $_GET not $_REQUEST…

Thanks 'am on it

Sponsor our Newsletter | Privacy Policy | Terms of Service