Ver Mensaje Individual
  #1 (permalink)  
Antiguo 26/12/2012, 09:13
santi2892009
 
Fecha de Ingreso: mayo-2012
Mensajes: 363
Antigüedad: 11 años, 11 meses
Puntos: 0
Php registro de usuarios

OLaa me podieis indicar q esta mal en esta archivo de regsitro.php:


<?php

include("config.php");

// connect to the mysql server
$link = mysql_connect($server, $db_user, $db_pass)
or die ("Could not connect to mysql because ".mysql_error());

// select the database
mysql_select_db($database)
or die ("Could not select database because ".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 "Sorry, there the username $username is already taken.<br>";
echo "<a href=register.html>Try again</a>";
exit;
} else {

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

// print a success message
echo "Your user account has been created!<br>";
echo "Now you can <a href=login.html>log in</a>";
}

?>


han abrirlo con dreamweaver me sale esto:

"; echo "Try again"; exit; } else { // insert the data $insert = mysql_query("insert into $table values ('NULL', '".$_POST['username']."', '".$_POST['password']."', '".$_POST['name1']."', '".$_POST['name2']."', '".$_POST['hotmail ']."', '".$_POST['website']."', 'images/avatar.jpg')") or die("Could not insert data because ".mysql_error()); // print a success message echo "Your user account has been created!
"; echo "Now you can log in"; } ?>

el fallo que tiene es q me sale todo el echo y lo de insertare en la tabla,seguro q es una tonteria pero no digo con ello alguien me ayuda.

un saludo y muchas gracias