<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$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"] == "REGISTRATION")) {
$insertSQL = sprintf("INSERT INTO `S and T R` (`School Name`, `School Contact No.`, `School Email ID`, `Fax Number`, `Teacher Name`, `Teacher Contact number`, `Teacher Email ID`, `T-size Teacher`, `Teacher Gender`) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['School_Name'], "text"),
GetSQLValueString($_POST['Contact Number (school)'], "text"),
GetSQLValueString($_POST['School Email ID'], "text"),
GetSQLValueString($_POST['Fax Number'], "text"),
GetSQLValueString($_POST['Teacher name'], "text"),
GetSQLValueString($_POST['Contact Number'], "text"),
GetSQLValueString($_POST['Teacher email ID'], "text"),
GetSQLValueString($_POST['T-size Teacher'], "text"),
GetSQLValueString($_POST['Gender'], "text"));
mysql_select_db($database_SBA, $SBA);
$Result1 = mysql_query($insertSQL, $SBA) or die(mysql_error());
}
mysql_select_db($database_SBA, $SBA);
$query_Recordset1 = "SELECT * FROM `S and T R`";
$Recordset1 = mysql_query($query_Recordset1, $SBA) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
the PHP code...i am not using PDO instead for my DB management i am using Mysql Workbench if that's what you were asking...
thanks to being considerate I really need this to be done, i am new to PHP and did some basic tutorials
To interact with a database you need to build a CRUD application. Basically, a set of PHP pages that is able to connect and Create/Read/Update/Delete data in the database.