Código 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"] == "form1")) {
$insertSQL = sprintf("INSERT INTO tblcontacto (StrNombre, StrMail, intTel) VALUES (%s, %s, %s)",
GetSQLValueString($_POST[''], "text"),
GetSQLValueString($_POST['StrMail'], "text"),
GetSQLValueString($_POST['intTel'], "text"));
mysql_select_db($database_con_pro, $con_pro);
$Result1 = mysql_query($insertSQL, $con_pro) or die(mysql_error());
}
?>
Código PHP:
<div id="mainContent">
<form action="<?php echo $editFormAction; ?>" method="post" id="form1">
<table>
<tr valign="baseline">
<td align="right">Nombre:</td>
<td><span id="sprytextfield1">
<input type="text" name="StrNombre" value="" size="32" />
<span class="textfieldRequiredMsg">Se necesita un valor.</span></span></td>
</tr>
<tr valign="baseline">
<td align="right">Mail:</td>
<td><span id="sprytextfield2">
<input type="text" name="StrMail" value="" size="32" />
<span class="textfieldRequiredMsg">Se necesita un valor.</span></span></td>
</tr>
<tr valign="baseline">
<td align="right">Telefono:</td>
<td><span id="sprytextfield3">
<input type="text" name="intTel" value="" size="32" />
<span class="textfieldRequiredMsg">Se necesita un valor.</span></span></td>
</tr>
<tr valign="baseline">
<td align="right"> </td>
<td><input type="submit" value="Enviar" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
Se agradece su ayuda =D
A algun mod, favor cambiar nombre de tema a Seguridad en formulario.
Gracais y disculpen.
Gracias !!