Hi ppl,
I am trying to insert records into my database using a form. this works. but after this i would like the records to be displayed onto another page.. the database gets updated but the webpage i want the data to be displayed remains empty....any suggestions..
code so far.
[PHP]
<?php require_once('C onnections/mysql_connect.p hp'); ?>
<?php
if (!function_exis ts("GetSQLValue String")) {
function GetSQLValueStri ng($theValue, $theType, $theDefinedValu e = "", $theNotDefinedV alue = "")
{
$theValue = get_magic_quote s_gpc() ? stripslashes($t heValue) : $theValue;
$theValue = function_exists ("mysql_real_es cape_string") ? mysql_real_esca pe_string($theV alue) : mysql_escape_st ring($theValue) ;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValu e) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theV alue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValu e : $theNotDefinedV alue;
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"] == "form2")) {
$insertSQL = sprintf("INSERT INTO `assignment submission sheet` (`Student number`, `Pathway / Course`, `Essay only`, `Marking tutor name`, `Module unit title`, `Module number`, `Assignment title`) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueStri ng($_POST['Student_number '], "int"),
GetSQLValueStri ng($_POST['Pathway__Cours e'], "text"),
GetSQLValueStri ng($_POST['Essay_only'], "int"),
GetSQLValueStri ng($_POST['Marking_tutor_ name'], "text"),
GetSQLValueStri ng($_POST['Module_unit_ti tle'], "text"),
GetSQLValueStri ng($_POST['Module_number'], "text"),
GetSQLValueStri ng($_POST['Assignment_tit le'], "text"));
mysql_select_db ($database_mysq l_connect, $mysql_connect) ;
$Result1 = mysql_query($in sertSQL, $mysql_connect) or die(mysql_error ());
$insertGoTo = "gygyui.php ";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insert GoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf( "Location: %s", $insertGoTo));
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO `assignment submission sheet` (`Student number`, `Pathway / Course`, `Essay only`, `Marking tutor name`, `Module unit title`, `Module number`, `Assignment title`) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueStri ng($_POST['Student_number '], "int"),
GetSQLValueStri ng($_POST['Pathway__Cours e'], "text"),
GetSQLValueStri ng($_POST['Essay_only'], "int"),
GetSQLValueStri ng($_POST['Marking_tutor_ name'], "text"),
GetSQLValueStri ng($_POST['Module_unit_ti tle'], "text"),
GetSQLValueStri ng($_POST['Module_number'], "text"),
GetSQLValueStri ng($_POST['Assignment_tit le'], "text"));
mysql_select_db ($database_mysq l_connect, $mysql_connect) ;
$Result1 = mysql_query($in sertSQL, $mysql_connect) or die(mysql_error ());
$insertGoTo = "gygyui.php ";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insert GoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf( "Location: %s", $insertGoTo));
}
mysql_select_db ($database_mysq l_connect, $mysql_connect) ;
$query_Recordse t2 = "SELECT * FROM `assignment submission sheet`";
$Recordset2 = mysql_query($qu ery_Recordset2, $mysql_connect) or die(mysql_error ());
$row_Recordset2 = mysql_fetch_ass oc($Recordset2) ;
$totalRows_Reco rdset2 = mysql_num_rows( $Recordset2);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitl ed Document</title>
</head>
<body>
<form action="<?php echo $editFormAction ; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baselin e">
<td nowrap="nowrap" align="right">S tudent number:</td>
<td><input name="Student_n umber" type="text" value="" size="32" maxlength="7" /></td>
</tr>
<tr valign="baselin e">
<td nowrap="nowrap" align="right">P athway / Course:</td>
<td><input name="Pathway__ Course" type="text" value="" size="32" maxlength="30" /></td>
</tr>
<tr valign="baselin e">
<td nowrap="nowrap" align="right">E ssay only:</td>
<td><input name="Essay_onl y" type="text" value="" size="32" maxlength="7" /></td>
</tr>
<tr valign="baselin e">
<td nowrap="nowrap" align="right">M arking tutor name:</td>
<td><input name="Marking_t utor_name" type="text" value="" size="32" maxlength="25" /></td>
</tr>
<tr valign="baselin e">
<td nowrap="nowrap" align="right">M odule unit title:</td>
<td><input name="Module_un it_title" type="text" value="" size="32" maxlength="30" /></td>
</tr>
<tr valign="baselin e">
<td nowrap="nowrap" align="right">M odule number:</td>
<td><input name="Module_nu mber" type="text" value="" size="32" maxlength="10" /></td>
</tr>
<tr valign="baselin e">
<td nowrap="nowrap" align="right">A ssignment title:</td>
<td><input name="Assignmen t_title" type="text" value="" size="32" maxlength="30" /></td>
</tr>
<tr valign="baselin e">
<td nowrap="nowrap" align="right">& nbsp;</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_resu lt($Recordset2) ;
?> [/PHP]
I am trying to insert records into my database using a form. this works. but after this i would like the records to be displayed onto another page.. the database gets updated but the webpage i want the data to be displayed remains empty....any suggestions..
code so far.
[PHP]
<?php require_once('C onnections/mysql_connect.p hp'); ?>
<?php
if (!function_exis ts("GetSQLValue String")) {
function GetSQLValueStri ng($theValue, $theType, $theDefinedValu e = "", $theNotDefinedV alue = "")
{
$theValue = get_magic_quote s_gpc() ? stripslashes($t heValue) : $theValue;
$theValue = function_exists ("mysql_real_es cape_string") ? mysql_real_esca pe_string($theV alue) : mysql_escape_st ring($theValue) ;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValu e) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theV alue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValu e : $theNotDefinedV alue;
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"] == "form2")) {
$insertSQL = sprintf("INSERT INTO `assignment submission sheet` (`Student number`, `Pathway / Course`, `Essay only`, `Marking tutor name`, `Module unit title`, `Module number`, `Assignment title`) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueStri ng($_POST['Student_number '], "int"),
GetSQLValueStri ng($_POST['Pathway__Cours e'], "text"),
GetSQLValueStri ng($_POST['Essay_only'], "int"),
GetSQLValueStri ng($_POST['Marking_tutor_ name'], "text"),
GetSQLValueStri ng($_POST['Module_unit_ti tle'], "text"),
GetSQLValueStri ng($_POST['Module_number'], "text"),
GetSQLValueStri ng($_POST['Assignment_tit le'], "text"));
mysql_select_db ($database_mysq l_connect, $mysql_connect) ;
$Result1 = mysql_query($in sertSQL, $mysql_connect) or die(mysql_error ());
$insertGoTo = "gygyui.php ";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insert GoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf( "Location: %s", $insertGoTo));
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO `assignment submission sheet` (`Student number`, `Pathway / Course`, `Essay only`, `Marking tutor name`, `Module unit title`, `Module number`, `Assignment title`) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueStri ng($_POST['Student_number '], "int"),
GetSQLValueStri ng($_POST['Pathway__Cours e'], "text"),
GetSQLValueStri ng($_POST['Essay_only'], "int"),
GetSQLValueStri ng($_POST['Marking_tutor_ name'], "text"),
GetSQLValueStri ng($_POST['Module_unit_ti tle'], "text"),
GetSQLValueStri ng($_POST['Module_number'], "text"),
GetSQLValueStri ng($_POST['Assignment_tit le'], "text"));
mysql_select_db ($database_mysq l_connect, $mysql_connect) ;
$Result1 = mysql_query($in sertSQL, $mysql_connect) or die(mysql_error ());
$insertGoTo = "gygyui.php ";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insert GoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf( "Location: %s", $insertGoTo));
}
mysql_select_db ($database_mysq l_connect, $mysql_connect) ;
$query_Recordse t2 = "SELECT * FROM `assignment submission sheet`";
$Recordset2 = mysql_query($qu ery_Recordset2, $mysql_connect) or die(mysql_error ());
$row_Recordset2 = mysql_fetch_ass oc($Recordset2) ;
$totalRows_Reco rdset2 = mysql_num_rows( $Recordset2);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitl ed Document</title>
</head>
<body>
<form action="<?php echo $editFormAction ; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baselin e">
<td nowrap="nowrap" align="right">S tudent number:</td>
<td><input name="Student_n umber" type="text" value="" size="32" maxlength="7" /></td>
</tr>
<tr valign="baselin e">
<td nowrap="nowrap" align="right">P athway / Course:</td>
<td><input name="Pathway__ Course" type="text" value="" size="32" maxlength="30" /></td>
</tr>
<tr valign="baselin e">
<td nowrap="nowrap" align="right">E ssay only:</td>
<td><input name="Essay_onl y" type="text" value="" size="32" maxlength="7" /></td>
</tr>
<tr valign="baselin e">
<td nowrap="nowrap" align="right">M arking tutor name:</td>
<td><input name="Marking_t utor_name" type="text" value="" size="32" maxlength="25" /></td>
</tr>
<tr valign="baselin e">
<td nowrap="nowrap" align="right">M odule unit title:</td>
<td><input name="Module_un it_title" type="text" value="" size="32" maxlength="30" /></td>
</tr>
<tr valign="baselin e">
<td nowrap="nowrap" align="right">M odule number:</td>
<td><input name="Module_nu mber" type="text" value="" size="32" maxlength="10" /></td>
</tr>
<tr valign="baselin e">
<td nowrap="nowrap" align="right">A ssignment title:</td>
<td><input name="Assignmen t_title" type="text" value="" size="32" maxlength="30" /></td>
</tr>
<tr valign="baselin e">
<td nowrap="nowrap" align="right">& nbsp;</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_resu lt($Recordset2) ;
?> [/PHP]
Comment