<?php require_once('Connections/Connection.php'); ?>
<?php require_once('Connections/Connection.php'); ?>
<?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;
}
}
mysql_select_db($database_Connection, $Connection);
$query_Recordset1 = "SELECT * FROM p_register_tbl";
$Recordset1 = mysql_query($query_Recordset1, $Connection) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form3")) {
$insertSQL = sprintf("INSERT INTO p_register_tbl (P_ID, P_Name, P_Desc) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['P_ID'], "int"),
GetSQLValueString($_POST['P_Name'], "text"),
GetSQLValueString($_POST['P_Desc'], "text"));
mysql_select_db($database_Connection, $Connection);
$Result1 = mysql_query($insertSQL, $Connection) or die(mysql_error());
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form3")) {
$insertSQL = sprintf("INSERT INTO p_register_tbl (P_ID, `P_Name`, `P_Desc`) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['P_ID'], "int"),
GetSQLValueString($_POST['P_Name'], "text"),
GetSQLValueString($_POST['P_Desc'], "text"));
mysql_select_db($database_Connection, $Connection);
$Result1 = mysql_query($insertSQL, $Connection) or die(mysql_error());
}
?>
<?php
function mysql_next_id($P_Register_tbl) {
$result = mysql_query('SHOW TABLE STATUS LIKE "'.$P_Register_tbl.'"');
$rows = mysql_fetch_assoc($result);
return $rows['auto_increment'];
}
?>
i am a new beginner ,using the recordset to create a program register form but dun knoe it is right or wrong...
Help me have a check..
besides that, i also dun knoe how to check the record if it is already exist in db...
<?php require_once('Connections/Connection.php'); ?>
<?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;
}
}
mysql_select_db($database_Connection, $Connection);
$query_Recordset1 = "SELECT * FROM p_register_tbl";
$Recordset1 = mysql_query($query_Recordset1, $Connection) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form3")) {
$insertSQL = sprintf("INSERT INTO p_register_tbl (P_ID, P_Name, P_Desc) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['P_ID'], "int"),
GetSQLValueString($_POST['P_Name'], "text"),
GetSQLValueString($_POST['P_Desc'], "text"));
mysql_select_db($database_Connection, $Connection);
$Result1 = mysql_query($insertSQL, $Connection) or die(mysql_error());
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form3")) {
$insertSQL = sprintf("INSERT INTO p_register_tbl (P_ID, `P_Name`, `P_Desc`) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['P_ID'], "int"),
GetSQLValueString($_POST['P_Name'], "text"),
GetSQLValueString($_POST['P_Desc'], "text"));
mysql_select_db($database_Connection, $Connection);
$Result1 = mysql_query($insertSQL, $Connection) or die(mysql_error());
}
?>
<?php
function mysql_next_id($P_Register_tbl) {
$result = mysql_query('SHOW TABLE STATUS LIKE "'.$P_Register_tbl.'"');
$rows = mysql_fetch_assoc($result);
return $rows['auto_increment'];
}
?>
i am a new beginner ,using the recordset to create a program register form but dun knoe it is right or wrong...
Help me have a check..
besides that, i also dun knoe how to check the record if it is already exist in db...