i need to update a database table using variables in unusual places here are the update statements
-
mysql_query("UPDATE 'grades' SET '$class' = '$grade' WHERE student='$student'");
-
mysql_query("UPDATE 'assignments' SET '$class' = '$grade' WHERE student='$student'");
-
mysql_query("UPDATE 'comments' SET '$class' = '$grade' WHERE student='$student'");
-
now i was just showed by ron how to recive post stuff and that is where the variables come from so i am not even sure if i am getting the variables from the other page. i did try to display all of those variables but with my php skills the echo options might have their own problems so here is the rest of the code
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-
<html>
-
<head>
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-
<title>Untitled Document</title>
-
<?
-
-
session_start(); // Use session variable on this page. This function must put on the top of page.
-
if(!session_is_registered("teacher")){ // if session variable "username" does not exist.
-
header("location:login.php"); // Re-direct to index.php
-
}
-
-
?>
-
<?
-
// Connect database.
-
$host="localhost"; // Host name.
-
$db_user="rcadmin"; // MySQL username.
-
$db_password="nsds2004"; // MySQL password.
-
$database="RCA"; // Database name.
-
$RCA = mysql_pconnect($host, $db_user, $db_password) or trigger_error(mysql_error(),E_USER_ERROR);
-
mysql_select_db($database, $RCA);
-
$login=$_POST('login');
-
$class=$_POST('job_select');
-
$grade=$_POST('job_select');
-
$assignment=$_POST('job_select');
-
$comments=$_POST('job_select');
-
//this section updates the database
-
$grade = "grade";
-
$assignments = "assignments";
-
$comments = "comments";
-
$student = "student";
-
$class = "class";
-
if (isset($_POST['grade']))
-
$grade = strip_tags($_POST['grade']);
-
if (isset($_POST['assigments']))
-
$assignments = strip_tags($_POST['assignments']);
-
if (isset($_POST['comments']))
-
$comments = strip_tags($_POST['comments']);
-
if (isset($_POST['student']))
-
$student = strip_tags($_POST['student']);
-
if (isset($_POST['classs']))
-
$class = strip_tags($_POST['classs']);
-
-
-
mysql_query("UPDATE 'grades' SET $class = '$grade' WHERE student='$student'");
-
mysql_query("UPDATE assignments SET '$class' = '$grade' WHERE student='$student'");
-
mysql_query("UPDATE comments SET $class = '$grade' WHERE student='$student'");
-
?>
-
</head>
-
-
<body>
-
<?
-
echo $grade, "<br />";
-
echo $assignments , "<br />";
-
echo $comments , "<br />";
-
echo $student , "<br />";
-
echo $class , "<br />";
-
-
?>
-
</body>
-
</html>
-