Hola estoy haciendo un script en PHP que me permita insertar usuarios en una base de datos MySQL. La BD me está contando las inserciones pero no me inserta nada.
La BD: Esta formada por los campos id_user, nombre, apellidos, email
Este es el archivo index.php que nuevamente lo revisé y cambié algunas cosas.
Código PHP:
<?php
$nombre = $HTTP_POST_VARS['name'];
$apellidos = $HTTP_POST_VARS['lastname'];
$email = $HTTP_POST_VARS['mail'];
?>
<html>
<head>
<title>Documento sin título</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form1" method="post" action="insert.php">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="9%">Nombre:</td>
<td width="91%"><input name="name" type="text" id="name" size="25" maxlength="25"></td>
</tr>
<tr>
<td>Apellidos:</td>
<td><input name="lastname" type="text" id="lastname" size="25" maxlength="25"></td>
</tr>
<tr>
<td>E_Mail:</td>
<td><input name="mail" type="text" id="mail" size="25" maxlength="25"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="Submit" value="Enviar"></td>
</tr>
</table>
</form>
</body>
</html>
y este otro el insert.php
Código PHP:
<?php
$host = "localhost";
$user = "";
$pass = "";
$db = "prueba";
$conecta = mysql_connect($host,$user,$pass);
if (!$conecta)
{
echo "Error:" .mysql_error();
}
$selec = mysql_select_db($db,$conecta);
mysql_query("INSERT INTO prueba (name,lastname,mail) VALUES ('$nombre','$apellidos','email')");
?>