<?php
session_start();
$makan = isset($_POST['makan']) ? $_POST['makan'] : 0;
if($makan){
$_SESSION['makan'] = $makan;
header("location: minum.php");
exit;
}
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$limit = 1;
$start = ($page - 1) * $limit;
$sql = "select * from t_makanan limit $start, $limit";
$hs = mysql_query($sql);
if(mysql_num_rows($hs)){
echo '<form method="post" action="makan.php?page='.($page+1).'">';
$makanan = mysql_fetch_array($hs);
echo "Apakah Anda sarapan ".$makanan['nm_makanan']."?<br/>";
echo '<input type="radio" name="makan" value="'.$makanan['id_makanan'].'"/> Ya';
echo '<input type="radio" name="makan" value="0"/> Tidak';
echo '<input type="submit" value="Next" name="next"/>';
echo '</form>';
}else{
$_SESSION['makan'] = 0;
header("location: minum.php");
exit;
}
minum.php<?php
session_start();
$minum = isset($_POST['minum']) ? $_POST['minum'] : 0;
if($minum){
$_SESSION['minum'] = $minum;
header("location: hasil.php");
exit;
}
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$limit = 1;
$start = ($page - 1) * $limit;
$sql = "select * from t_minuman limit $start, $limit";
$hs = mysql_query($sql);
if(mysql_num_rows($hs)){
echo '<form method="post" action="minum.php?page='.($page+1).'">';
$makanan = mysql_fetch_array($hs);
echo "Apakah Anda minum ".$makanan['nm_minuman']."?<br/>";
echo '<input type="radio" name="minum" value="'.$makanan['id_minuman'].'"/> Ya';
echo '<input type="radio" name="minum" value="0"/> Tidak';
echo '<input type="submit" value="Next" name="next"/>';
echo '</form>';
}else{
$_SESSION['minum'] = 0;
header("location: hasil.php");
exit;
}
lalu file hasil.php<?php
session_start();
echo "Makanan:'.$_SESSION['makan'];
echo 'Minuman:'.$_SESSION['minum'];