estoy modificando un form pero no se como hacerle el insert a la base de datos... aqui les muestro
mi formulario
Código PHP:
<form method="post" id="registerForm" action="register.php">
<table align="center" cellpadding="2" cellspacing="0">
<tr>
<td width="120" style="width:120px"><div align="right" class="textoResto">Nombre: </div></td>
<td width="172"><div align="left" class="string">
<input name="nombre" type="text" class="input" id="nombre" value="" size="32" />
</div> </td>
</tr>
<tr>
<td class="textoResto" style="width:120px"><div align="right">Apellido: </div></td>
<td><div align="left">
<input name="apellido" class="input" type="text" id="apellido" value="" size="32" />
</div></td>
</tr>
<tr>
<td class="textoResto" style="width:120px"><div align="right">Usuario: </div></td>
<td><div align="left">
<input name="usuario" type="text" class="input" id="usuario" value="" size="32" />
</div> </td>
</tr>
<tr>
<td class="textoResto" style="width:120px"><div align="right">Contraseña: </div></td>
<td><div align="left">
<input name="pass" type="password" class="input" id="pass" value="" size="32" />
</div></td>
</tr>
<tr>
<td class="textoResto" style="width:120px"><div align="right">Repetir Contraseña: </div></td>
<td><div align="left">
<input name="re_pass" type="password" class="input" id="re_pass" value="" size="32" />
</div></td>
</tr>
<tr>
<td class="textoResto" style="width:120px"><div align="right">E-Mail: </div></td>
<td><div align="left">
<input name="mail" type="text" class="input" id="mail" value="" size="32" />
</div></td>
</tr>
<tr>
<td style="width:120px"><div align="right" class="textoResto">C.I. / RIF.:</div></td>
<td><input name="cedula" type="text" class="input" id="cedula" value="" size="32" /></td>
</tr>
<tr>
<td style="width:120px"><div align="right" class="textoResto">Teléfono: </div></td>
<td><input name="telefono" type="text" class="input" id="telefono" value="" size="32" /></td>
</tr>
<tr>
<td style="width:120px"><div align="right" class="textoResto">Fecha: </div></td>
<td><div align="left">
<input name="fecha" type="text" class="input" id="fecha" value="" size="25" />
</div></td>
</tr>
<tr>
<td colspan="2"><div align="right">
<input type="image" name="register" class="submit-btn" src="btn.gif" alt="submit" title="submit" />
</div></td>
</tr>
</table>
</form>
register.php
Código PHP:
<?php
include('functions.php');
if ($_POST['nombre']=='' || strlen($_POST['nombre'])<3)
{
$errors[] = 'Nomnbre debe poseer al menos 3 letras.';
}
if ($_POST['apellido']=='' || strlen($_POST['apellido'])<3)
{
$errors[] = 'Apellido debe poseer al menos 3 letras.';
}
if ($_POST['usuario']=='' || alpha_numeric($_POST['usuario'])==FALSE)
{
$errors[] = 'Usuario debe contener valores alfa-numéricos';
}
if ($_POST['pass']=='' || alpha_numeric($_POST['pass'])==FALSE)
{
$errors[] = 'A password is required and must be alpha-numeric';
}
if ($_POST['pass']!=$_POST['re_pass'])
{
$errors[] = 'The two passwords must match';
}
if (valid_email($_POST['mail'])==FALSE)
{
$errors[] = 'Please supply a valid email address';
}
if ($_POST['cedula']=='' || strlen($_POST['cedula'])<3)
{
$errors[] = 'Cedula name is required and must contain 3 characters or more';
}
if ($_POST['telefono']=='' || strlen($_POST['telefono'])<3)
{
$errors[] = 'Telefono name is required and must contain 3 characters or more';
}
if ($_POST['fecha']=='' || strlen($_POST['fecha'])<3)
{
$errors[] = 'Fecha name is required and must contain 3 characters or more';
}
if(is_array($errors))
{
echo '<p class="error"><b>The following errors occured</b></p>';
while (list($key,$value) = each($errors))
{
echo '<span class="error">'.$value.'</span><br />';
}
}
else {
//do something here----store to db, send email
echo '<p><b>Success!</b></p>';
echo '<span>Your registration was successfully processed. You may login and start using your account. Thank you for registering !</span>';
}
?>
Código PHP:
<?php
function alpha_numeric($str)
{
return ( ! preg_match("/^([-a-z0-9])+$/i", $str)) ? FALSE : TRUE;
}
function valid_email($str)
{
return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;
}
?>
podrian ayudarme??