I am little confused as to where, which code goes...
full code:
Code: Select all
<?php require_once('file:///C|/xampp/htdocs/Connections/mysql_connect.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO robs_enterprise (ID, `Student number`, `Pathway / Course`, `Essay only`, `Marking tutor name`, `Module unit title`, `Module number`, `Assignment title`, `Time`) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['ID'], "int"),
GetSQLValueString($_POST['Student_number'], "int"),
GetSQLValueString($_POST['Pathway__Course'], "text"),
GetSQLValueString($_POST['Essay_only'], "text"),
GetSQLValueString($_POST['Marking_tutor_name'], "text"),
GetSQLValueString($_POST['Module_unit_title'], "text"),
GetSQLValueString($_POST['Module_number'], "text"),
GetSQLValueString($_POST['Assignment_title'], "text"),
GetSQLValueString($_POST['Time'], "date"));
mysql_select_db($database_mysql_connect, $mysql_connect);
$Result1 = mysql_query($insertSQL, $mysql_connect) or die(mysql_error());
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO robs_enterprise (`Student number`) VALUES (%s)",
GetSQLValueString($_POST['Student_number'], "int"));
mysql_select_db($database_mysql_connect, $mysql_connect);
$Result1 = mysql_query($insertSQL, $mysql_connect) or die(mysql_error());
}
mysql_select_db($database_mysql_connect, $mysql_connect);
$query_Recordset1 = "SELECT robs_enterprise.`Student number` FROM robs_enterprise";
$Recordset1 = mysql_query($query_Recordset1, $mysql_connect) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<p> </p>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Student number:</td>
<td><input type="text" name="Student_number" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Insert record" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>