Form Best Practice/Help...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



	I am working on an application and I am not having a lot of luck
getting a form to behave the way I want.  I am trying to keep the form "self
referencing", not sure if that is the correct terminology.  The form is an
approval form that queries a database to create a list of checkboxes.  These
checkbox selections shall then, upon submit, update the database table with
an approval timestamp and fire off an e-mail to one of our administrators to
take action.  The problem I am having is that once the submit button is
clicked the page is not displaying the results I am expecting.  This leads
me to the obvious conclusion that something in the flow control of my page
is incorrect.
	My questions are regarding the way in which I am laying out this
page.  I am trying to keep the page self referencing such that there are
fewer pages to keep track of, and I also feel this looks more professional
since the approval process will only involve a single URL.  Currently I am
simply trying to get a click on the submit button to display a "Done"
message to test the flow control.  Now, on to the questions...  Is this type
of flow control logic a good idea?  Is there a better way to implement this
process?  What am I missing that is causing this flow control logic to fail?
	OK.  Here is the code:

<?php require_once('useraccounts.lib.php');
$safe_verify_string = urldecode($_REQUEST['verify_string']);

mysql_select_db($database, $Prod);
$query = "SELECT * FROM accounts WHERE verifyurl='{$safe_verify_string}'";
$result = mysql_query($query, $Prod) or die(mysql_error());
# $test = mysql_num_rows($result);
$list = mysql_fetch_assoc($result);
$id = split('-', $list['id-sys']);

if (isset($cnt)) {
  echo "<p align=\"center\"><font color=\"#0033FF\" size=\"5\">Done.</p>";
}
?>

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<p align="center"><font color="#0033FF" size="5">Welcome to the New User
Account Approval system.</font> 
</p>
<?php
if (mysql_num_rows($result) == 0 ) {
  echo "<p align=\"center\">No accounts pending approval were found for this
request. </p>";
  echo "<p align=\"center\">Please contact the SA Team if you are having
problems with this request system.</p>";
} else {
  echo "<p align=\"center\">The following accounts for $id[0] have been
requested and require your approval prior to creation. </p>";
  echo "<p align=\"center\">";
  $test1 = CheckboxList($query, $CheckboxText, $link);
}

?>
</p>
</body>
</html>

	The function "CheckboxList" is called from the useraccounts.lib.php
script and is returning the $cnt variable.  This $cnt variable is only used
as a mechanism to create the checkbox list of systems in four columns.  I
decided to check for the existence of this variable since it must be set if
the "CheckboxList" function is called.  Below is the "CheckboxList"
function:

function CheckboxList($query, $CheckboxText, $link) {
  global $cnt;
  $cnt = 1;
  $result1 = mysql_query($query);
  echo "<form name=\"form1\" method=\"get\" action=\"$link\">";
  echo "<table border=\"0\" align=\"center\">";
  while ($list = mysql_fetch_assoc($result1)) {
    $sys = split('-', $list['id-sys']);
    if ($cnt == 1) { 
      $cnt = 2; 
      echo "<tr><td width=\"161\"><input name=\"system[]\" type=\"checkbox\"
value=\"$sys[1]\">";
      echo $sys[1]."</td>";
    } elseif ($cnt == 2) { 
	  $cnt = 3;
      echo "<td width=\"161\"><input name=\"system[]\" type=\"checkbox\"
value=\"$sys[1]\">";
      echo $sys[1]."</td>";
    } elseif ($cnt == 3) { 
	  $cnt = 4;
      echo "<td width=\"161\"><input name=\"system[]\" type=\"checkbox\"
value=\"$sys[1]\">";
      echo $sys[1]."</td>";
	} elseif ($cnt == 4) { 
	  $cnt = 1;
      echo "<td width=\"161\"><input name=\"system[]\" type=\"checkbox\"
value=\"$sys[1]\">";
      echo $sys[1]."</td></tr>";
	}
  }
  echo "</table>";
  if ($CheckboxText) {
    echo "<p align=\"center\"><font size=\"4\">$CheckboxText</font></p>";
  }
  echo "<div align=\"center\"><input type=\"submit\" name=\"Submit\"
value=\"Submit\"></div></form>";
  return $cnt;
}

	Thanks in advance, and again, for the help.
Scott Nipp
Phone:  (214) 858-1289
E-mail:  sn4265@sbc.com
Web:  http:\\ldsa.sbcld.sbc.com



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux