after login, go to this page. client will click those button then view each recipe they click.


list.php

<?php
session_start();
if(!isset($_SESSION['myusername'])&&!isset($_SESSION['mypassword'])) {
header('Location:401.php');
}
?>

<!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">
<head>
<!--for auto refresh--> 
<META HTTP-EQUIV=Refresh CONTENT="300; URL=http://localhost/recipe2/home.php">
<title>home</title>
</head>

<body>
<div align="left"><img src="Cookie Banner edited.jpg" width="1100" height="200" /></div>
<h2>My Account </h2>

<p>chef today : <?php echo $_SESSION['myusername']; ?> | <a href="logout.php">Logout</a> </p>
<p>&nbsp;</p>
<p>&nbsp;</p>

<form id="form1" name="form1" method="post" action="">
  <table width="200" border="0" align="center">
    <tr>
      <td>
        <label>
          <div align="center">
            <input type="submit" name="button" id="button" value="biskut" />
          </div>
        </label>      </td>
    </tr>
        <tr>
      <td><div align="center">
        <input type="submit" name="button2" id="button2" value="kek" />
      </div></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td><div align="center">
        <input type="submit" name="button3" id="button3" value="minuman" />
      </div></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td><div align="center">
        <input type="submit" name="button4" id="button4" value="kuih raya" />
      </div></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
    </tr>
     <tr>
      <td><div align="center">
        <input type="submit" name="button5" id="button5" value="puding" />
      </div></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td><div align="center">
        <input type="submit" name="button6" id="button6" value="western" />
      </div></td>
    </tr>
  </table>
  </form>

after select one of the button, will go to this page which view the detail follow the id_category (simple word following the button that they click)

home.php

<?php
session_start();
if(!isset($_SESSION['myusername'])&&!isset($_SESSION['mypassword'])) {
header('Location:401.php');
}
?>
<!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">
<head>
<!--for auto refresh--> 
<META HTTP-EQUIV=Refresh CONTENT="300; URL=http://localhost/recipe2/home.php">
<title>home</title>
</head>

<body>
<div align="left"><img src="Cookie Banner edited.jpg" width="1100" height="200" /></div>
<h2>My Account </h2>

chef today : <?php echo $_SESSION['myusername']; ?> | <a href="logout.php">Logout</a> 

<p>&nbsp;</p>
<p>&nbsp;</p>
<table width="1091" border="1" cellspacing="0" cellpadding="3">
<thead>
<th>no</th>
<th>name</th>
<th>ingredient</th>
<th>how to cook</th>
<th>category</th>
<th>action</th>
</thead>

<?php
include 'recipe2db.php';

$sql="SELECT r.*, c.category_name as nama_kategori FROM `recipe` r inner join category c on r.id_category=c.id_category order by r.id_category";

$result=mysql_query($sql);

$count=1;
// Start looping rows in mysql database.
while($rows=mysql_fetch_array($result)){
?>

<tr>
<td width ="15%"><div align="center"><? echo $count++ ?> </div> </td>
<td width="15%"><div align="center"><? echo $rows['name']; ?></div> </td>
<td width="25%"><div align="center"><? echo $rows['bahan']; ?></div> </td>
<td width="31%"><div align="center"><? echo $rows['cara']; ?></div> </td>
<td width="13%"><div align="center"><? echo $rows['nama_kategori']; ?></div> </td>
<td width="10%"><div align="center"><a href="delete.php?id=<? echo $rows['id']; ?>">delete</a>/<a href="update.php?id=<? echo $rows['id']; ?>">update</a></div></td>
</tr>

<?
// close while loop
}

// close connection
mysql_close();
?>
</table>


<form id="form1" name="form1" method="post" action="add.php">
  <label>
  <input type="submit" name="btnadd" id="btnadd" value="ADD new" />
 
  </label>
</form>
</body>
</html>

dearest programmer, help me to solve this...

What's the problem exactly?

commented: its good! +1

i don't know how to relate the button to the home.php? its must be follow the button request.
for example,

when user click on biskut's button, then at home.php page, it will display the biskut's data.

can u help me?

If you are just trying to go to 'home.php' when the button is clicked without submitting a form you can achieve that with a Java Script.
Insert this into into the head of the page :

<script type="text/javascript">
<!--
function MM_goToURL() { 
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
</script>

And this will be your button that directs you to home.php

<input name="example" type="submit" onclick="MM_goToURL('parent','home.php');return document.MM_returnValue" value="example" />

When clicked that will take you to home.php. You can change "name" and "value" to suit your needs.

Hope it helps!

thanks CFROG,

how about if i want it display their own data in the database according the button value?

If you want to display their own data I would think you could have them login as a member perhaps and then track their user names or id's through $_SESSION (sessions) and query the database accordingly depending on what information you want to display.

If you are unfamiliar with sessions you can try a tutorial as a good starting point.

try this : http://www.tizag.com/phpT/phpsessions.php

Did your button work ?

yes, its work.. thanks CFROG..
u help me a lot..

Ok, good deal, glad I could help ;-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.