Resulta que tengo un formulario. Quiero que haya un campo de confirmación del primero (nit), para asegurarme de que el registrante ingrese bien ese dato, y si lo escribio mal obviamente no deje enviar el formulario y le idique que los vuelva a escribir.
Aqui esta mi formulario:
Código PHP:
<?php require_once('Connections/segurodb.php'); ?>
<?php
///////Configuración/////
$mail_destinatario = '@';
///////Fin configuración//
if (isset ($_POST['Grabar'])) {
$headers .= "From: ".$_POST['empresa']. "";
if ( mail ($mail_destinatario, $_POST['email'], "Nit : ".$_POST['nit']." Telefono: ".stripcslashes ($_POST['telefono'])." Empresa : ".stripcslashes ($_POST['empresa']), $headers )) echo '
'; }
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;
}
}
// *** Redirect if username exists
$MM_flag="MM_insert";
if (isset($_POST[$MM_flag])) {
$MM_dupKeyRedirect="yaexiste.php";
$loginUsername = $_POST['nit'];
$LoginRS__query = sprintf("SELECT nit FROM registro WHERE nit=%s", GetSQLValueString($loginUsername, "int"));
mysql_select_db($database_segurodb, $segurodb);
$LoginRS=mysql_query($LoginRS__query, $segurodb) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
//if there is a row in the database, the username was found - can not add the requested username
if($loginFoundUser){
$MM_qsChar = "?";
//append the username to the redirect page
if (substr_count($MM_dupKeyRedirect,"?") >=1) $MM_qsChar = "&";
$MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername;
header ("Location: $MM_dupKeyRedirect");
exit;
}
}
$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 registro (nit, email, telefono, empresa) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['nit'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['telefono'], "text"),
GetSQLValueString($_POST['empresa'], "text"));
mysql_select_db($database_segurodb, $segurodb);
$Result1 = mysql_query($insertSQL, $segurodb) or die(mysql_error());
$insertGoTo = "gracias.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_segurodb, $segurodb);
$query_rc_registro = "SELECT * FROM registro";
$rc_registro = mysql_query($query_rc_registro, $segurodb) or die(mysql_error());
$row_rc_registro = mysql_fetch_assoc($rc_registro);
$totalRows_rc_registro = mysql_num_rows($rc_registro);
?><!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=iso-8859-1">
<title>titulo</title><link rel="shortcut icon" href="favicon.ico" />
<link href="css/css.css" rel="stylesheet" type="text/css" />
<script src="js/AC_RunActiveContent.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
</script>
</head>
<body>
<div align="center">
<table width="835" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<!--TABLA PRINCIPAL-->
<!--FIN TABLA PRINCIPAL-->
<tr>
<td width="835" height="328" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<!--TABLA SECUNDARIA PARA BANNER-->
<tr>
<td width="835" height="328" valign="top"><!--CELDA SECUNDARIA PARA BANNER-->
<script type="text/javascript">
</noscript></td>
</tr>
</table></td>
</tr>
<tr>
<td height="60" align="center" valign="middle" class="titulos_contenido">Apreciado cliente: Lléne el formulario en su totalidad, sin dejar campos vacíos o sin completar. Sus datos quedarán grabados y nosotros estaremos confirmando su registro en menos de 24 horas.</td>
</tr>
<tr>
<td height="188" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<!--DWLayoutTable-->
<tr>
<td width="835" height="188" align="center" valign="middle" class="titulo_internos"><form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td align="right" valign="middle" nowrap class="campos">Nit</td>
<td align="left" valign="middle"><input name="nit" type="text" class="campos2" id="nit" size="28" maxlength="28"></td>
</tr>
<tr valign="baseline">
<td align="right" valign="middle" nowrap class="campos">E-mail</td>
<td align="left" valign="middle"><input name="email" type="text" class="campos2" id="email" value="" size="28"></td>
</tr>
<tr valign="baseline">
<td align="right" valign="middle" nowrap class="campos">Telefono</td>
<td align="left" valign="middle"><input name="telefono" type="text" class="campos2" id="telefono" value="" size="10" maxlength="10"></td>
</tr>
<tr valign="baseline">
<td align="right" valign="middle" nowrap class="campos">Empresa</td>
<td align="left" valign="middle"><input name="empresa" type="text" class="campos2" id="empresa" value="" size="25" maxlength="25" /></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td align="center" valign="middle"><div align="center">
<input name="Grabar" type="submit" class="campos" id="Grabar" value="Grabar">
</div></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form></td>
</tr>
</table>
<tr>
<td height="37" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<!--TABLA BARRA-->
<tr>
<td width="835" height="37" valign="top"></noscript></td>
</tr>
</table>
<tr>
<td height="79" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<!--TABLA FIRMAS-->
<tr>
<td width="835" height="49" align="center" valign="middle" class="texto_firma"><!--TERMINA CELDA FIRMAS-->
<p>©2010</p></td>
</tr>
</table>
</table>
<tr><td height="52" colspan="3" align="center" valign="middle" class="campos2"> </td>
</tr>
<tr>
<td height="37" colspan="3" valign="top"> </td>
</tr>
<tr>
<td height="79" colspan="3" valign="top"> </td>
</tr>
</table>
</div>
</body>
</html>
<?php
mysql_free_result($rc_registro);
?>