Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Checking for useless codes/variables.

$
0
0
Hallo!

I am making a simple website as practice for professional website making. However, I don't have formal instructions with the PHP language and I would really like some advice, help or suggestions for the site I am making.

Its process is working fine, however, I can't seem to remove some notice and errors which I see has no effect on the main program. I have here the code for the most troublesome parts:

I think the error is on my line 5 with the 'command' index not being defined? I just copied these codes mostly from the tutorials I've read.
Posted Image
<?php
	include("includes/db.php");
	include("includes/functions.php");
	
	if($_REQUEST['command']=='add' && $_REQUEST['productid']>0){
		$pid=$_REQUEST['productid'];
		addtocart($pid,1);
		header("location:products.php");
		exit();
	}	
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


<title>Products</title>

<link href="index.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="index.css" type="text/css" media="screen" charset="utf-8" />

<script language="javascript">
	function addtocart(pid){
		document.form1.productid.value=pid;
		document.form1.command.value='add';
		document.form1.submit();
	}
</script>

</head>


<body>
<form name="form1">
	<input type="hidden" name="productid" />
    <input type="hidden" name="command" />
</form>
<div class="movie_box">
		<?php
			$result=mysql_query("select * from products") or die("select * from products"."<br/><br/>".mysql_error());
			while($row=mysql_fetch_array($result)){
		?>
			<table align="center">
			<tr>
			<td>
			<img src="<?php echo $row['picture']?>" />
            </td>
			<td width="350px">
			<h4><?php echo $row['name']?></h4><br />
            <?php echo $row['description']?><br />
            Price:<big style="color:green"> <em>php <?php echo $row['price']?></big></em><br /><br /> 	 
            <input type="button" value="Add to Cart" onclick="addtocart(<?php echo $row['serial']?>)" />
			</td>
			</tr>
			</table>
<hr size="1" />
        <?php } ?>
</div>
</body>
</html>


Viewing all articles
Browse latest Browse all 51036

Trending Articles