Location: PHPKode > projects > Standardized Test Practice Engine > stpe/admin/users.php
Copyright 2004 by Jonathan Bell and Daniel Perelman
This file is part of STPE - the Standardized Test Practice Engine.

    STPE is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    STPE is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Foobar; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

if($_POST['action'] == "add"){
	$code = substr(md5($_POST['newtopicnum'].$_POST['newsectionnum']."23".$thisnames),0,12);
	$sql = "INSERT INTO users
	$result = @mysql_query($sql, $connection) or die("Error #". mysql_errno() . ": " . mysql_error());

if($_POST['action'] == "update"){
		$newcode = substr(md5($thistopicnum.$thissectionnum."23".$thisnames),0,12);
		$sql = "UPDATE users SET topicnum='$thistopicnum', topicdesc='$thistopicdesc', sectionnum='$thissectionnum', sectiondesc='$thissectiondesc', names='$thisnames', code='$newcode', teachername='$thisteacher' WHERE id='$x'";
		$result = mysql_query($sql, $connection) or die("Error #". mysql_errno() . ": " . mysql_error());


$sql = "SELECT * FROM `users` order by id";
$total_result = @mysql_query($sql, $connection) or die("Error #". mysql_errno() . ": " . mysql_error());
$total_found = @mysql_num_rows($total_result);

$x = 0;
while ($row = mysql_fetch_array($total_result)) {

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

<title><?php echo $site_name; ?>: Admin</title>

<link rel="stylesheet" type="text/css" href="../style.css" />
	<form action="index.php" method="post">
	<p>Current users:
	<input type="hidden" name="action" value="update" /></p>
	<tr><th>Topic Number</th><th>Topic Descripsion</th><th>Section Number</th><th>Section Description</th><th>Names</th>
	foreach($id as $key => $thisid){
		echo '<tr><td><input type="text" name="topicnumnew'.$thisid.'" value="'.$topicnum[$key].'" /></td>
		<td><input type="text" name="topicdescnew'.$thisid.'" value="'.$topicdesc[$key].'" /></td>
		<td><input type="text" name="sectionnumnew'.$thisid.'" value="'.$sectionnum[$key].'" /></td>
		<td><input type="text" name="sectiondescnew'.$thisid.'" value="'.$sectiondesc[$key].'" /></td>
		<td><input type="text" name="namesnew'.$thisid.'" value="'.$names[$key].'" /></td>
		<td><input type="text" name="teachernamenew'.$thisid.'" value="'.$teachername[$key].'" /></td>
		echo '<td>'.$code[$key].'</td></tr>';
	echo "</table>";
	echo "<p><input type=\"hidden\" name=\"count\" value=\"$thisid\" />";
	<input type="submit" name="Update" value="Update" /><input type="reset" /><br /></p></form>
	<form action="index.php" method="post">
	<p>Add a new section:
	<input type="hidden" name="action" value="add" /></p>
	<tr><th>Topic Number</th><th>Topic Descripsion</th><th>Section Number</th><th>Section Description</th><th>Names</th><th>Teacher Name</th></tr>
	<tr><td><input type="text" name="newtopicnum" /></td><td><input type="text" name="newtopicdesc" /></td><td><input type="text" name="newsectionnum" /></td><td>
	<input type="text" name="newsectiondesc" /></td><td><input type="text" name="newnames" /></td><td><input type="text" name="newteachername" /></tr>
	<p><input type="submit" name="Add new" value="Add new" /></p>
	<p style="text-align: right;"><br />
		  <a href="http://jigsaw.w3.org/css-validator/">
  <img style="border:0;width:88px;height:31px"
       alt="Valid CSS!" />
      <a href="http://validator.w3.org/check/referer"><img
          alt="Valid XHTML 1.0!" height="31" width="88" /></a>
			Fine print: Created by Jonathan Bell and Daniel Perelman. Everything here is the property of Jonathan Bell and Daniel Perelman, 
			except for the subject reviews and quizzes, which are the property of the creators and are credited. Neither Jonathan 
			Bell nor Daniel Perelman can be held responsible for the use or misuse of the information provided on this website. 
			No part of this website may be reproduced without prior written position from Jonathan Bell and Daniel Perelman. 
			"Reproduced" refers to both the code of the site, the database, and the pages created by them. 
			Your use of this information is at your own risk. This site is not recognized, endorsed, or affiliated with the 
			College Board. The use of this site may or may not improve your SAT II chemistry scores.
Return current item: Standardized Test Practice Engine