0) { $p = $start - 25; if ($p < 0) { $p = 0; } $previous = "Previous 25"; } $next = ''; $n = $start + 25; $query = "select count(*) from lordwish where `ignore`=0 order by title limit $n,25"; $res = mysql_query($query); $row = mysql_fetch_row($res); mysql_free_result($res); if ($row[0] > 0) { $next = "Next 25"; } $nav = <<
 
 
  Legend of the Red Dragon - Wish List
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
$previous $next
STOP; if (($previous != '') or ($next != '')) { print $nav; } $query = "select id,title,wish,who from lordwish where `ignore`=0 order by id limit $start,25"; $res = mysql_query($query); if ($res) { if (mysql_num_rows($res) > 0 ) { while ($row = mysql_fetch_assoc($res)) { extract($row); print <<» $title submitted by $who $wish   STOP; } if (($previous != '') or ($next != '')) { print $nav; } } else { print "No wishes to list.\n"; } mysql_free_result($res); } else { print "Sorry. Can't hit the database. Try again later.\n"; } print " \n"; if ($_SESSION['uid'] > 0) { print <<(A)dd a Wish STOP; } else { print <<(L)ogin so you can add a Wish STOP; } print <<(Q)uit to Main
STOP; } function addWishScreen ($msg='',$title='',$wish='') { print <<

$msg

Title
 
Wish Description

  (R)eturn to Wish List
(Q)uit to Main
STOP; } function saveWish () { global $_REQUEST; if ($_REQUEST['title'] == '') { addWishScreen('Title cannot be blank',$_REQUEST['title'],$_REQUEST['wish']); return; } if ($_REQUEST['wish'] == '') { addWishScreen('Wish cannot be blank',$_REQUEST['title'],$_REQUEST['wish']); return; } $title = safe_mysql($_REQUEST['title']); $wish = safe_mysql($_REQUEST['wish']); $who = safe_mysql($_SESSION['uname']); $query = "select count(*),who from lordwish where `ignore` = 0 and title like $title and wish like $wish"; $res = mysql_query($query); $row = mysql_fetch_row($res); mysql_free_result($res); if ($row[0] == 0) { $query = "insert into lordwish (title,wish,who) values ($title,$wish,$who)"; mysql_query($query); } else { addWishScreen("That wish has already been added by {$row[1]}"); return; } print <<

You wish has been saved successfully.

  (R)eturn to Wish List
(Q)uit to Main
STOP; } include('inc/startup.php'); $action = getArrayVal($_REQUEST, 'action', ''); if ($action == 'add') { addWishScreen(); } elseif ($action == 'save') { saveWish(); } else { listWishes(); } include('inc/finish.php'); ?> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-