Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/01/2012, 16:02
kfh1992
 
Fecha de Ingreso: diciembre-2011
Mensajes: 414
Antigüedad: 12 años, 5 meses
Puntos: 1
Configurando el envío de datos con php

Hola, estoy estudiando diversas maneras de enviar datos con php y me he encontrado un sistema de usuarios que utiliza este formato

$insert = mysql_query("insert into $table values ('NULL', '".$_POST['username']."', '".$_POST['password']."', '".$_POST['name1']."', '".$_POST['name2']."', '".$_POST['email']."', '".$_POST['website']."', 'images/avatar.jpg')")
or die("Could not insert data because ".mysql_error());

Cuando yo utilizo desde siempre el siguiente

$name = $_POST["name"];
$surname = $_POST["surname"];
$date = $_POST["date"];
$email = $_POST["email1"];
$email2 = $_POST["email2"];
$password1 = $_POST["password1"];
$password2 = $_POST["password2"];
$alias = $_POST["alias"];
$consulta ="insert into users values('$id','$name','$surname','$mail','$password ','$alias','$permisos')";


Sería lo mismo ? Porque hay una cosa que no entiendo como tendria que adaptar los parametros al siguiente formulario

Lo intento adaptar y no lo consigo :(

El formulario html es el siguiente

<form action="register1.php" method="post" onSubmit="return validate()">
<p>Nombre <br />
<input type="text" name="name" size="20" id="name">
<br>
Apellidos<br />
<input type="text" name="surname" size="20" id="surname">
<br>
Email
<br />
<input type="text" name="mail" size="20" id="mail">
<p> Contraseña <br />
<input type="text" name="password" size="20" id="password">
<br>
Alias<br />
<input type="text" name="alias" size="20" id="alias">
<br>
<br>
<input type="submit" value="Registro">
</form>

y el archivo php que estoy estudiando el siguiente

include("config.php");

// connect to the mysql server
$link = mysql_connect($server, $db_user, $db_pass)
or die ("No te puedes conectar ".mysql_error());

// select the database
mysql_select_db($database)
or die ("No puedes seleccionar la bd".mysql_error());

// check if the username is taken
$check = "select id from $table where username = '".$_POST['username']."';";
$qry = mysql_query($check)
or die ("Could not match data because ".mysql_error());
$num_rows = mysql_num_rows($qry);
if ($num_rows != 0) {
echo "Ya esta siendo usado.<br>";
echo "<a href=register.html>Intentalo otra vez</a>";
exit;
} else {

// insert the data
$insert = mysql_query("insert into $table values ('NULL', '".$_POST['username']."', '".$_POST['password']."', '".$_POST['name1']."', '".$_POST['name2']."', '".$_POST['email']."', '".$_POST['website']."', 'images/avatar.jpg')")
or die("Could not insert data because ".mysql_error());


// print a success message
echo "Tu cuenta ha sido creada<br>";
}

La bd esta configurada asi

http://img71.xooimage.com/files/8/2/2/permisos-307a04c.png

Última edición por kfh1992; 12/01/2012 a las 16:20