Código PHP:
<form enctype="multipart/form-data" name="form1" method="post" action="">
<table>
<tr>
<td>
Nic</td><td> <INPUT maxLength="10" size="25" name="nick"></td><tr>
<td>Clave</td><td> <INPUT type="password" maxLength="25" size="25" value="" name="clave"></td>
<tr><td>Repita la clave</td><td> <INPUT type="password" maxLength="25" size="25" value="" name="cpclave"></td></tr>
<tr><td>Email</td><td><INPUT maxLength="25" size="25" name="email"></td></tr>
<tr><td>Nom</td><td><INPUT maxLength="10" size="25" name="nom"></td>
<tr><td>Cognom</td><td><INPUT maxLength="20" size="25" name="cognom"></td></tr>
<tr><td>Foto</td><td><input type="hidden" name="MAX_FILE_SIZE" value="100000"><input name="imagen" type="file" size="25"> </td></tr>
<tr><td>Telèfon</td><td><INPUT maxLength="9" size="25" name="telf"></td></tr>
<tr><td>Codi Postal</td><td><INPUT maxLength="5" size="25" name="CP"></td></tr>
<tr><td>Domicili</td><td><INPUT maxLength="25" size="25" name="domicili"></td></tr>
<tr><td>DNI</td><td><INPUT maxLength="9" size="25" name="dni"></td></tr>
<tr><td>
<INPUT name="submit" type="submit" value="Registra't!"></td></tr></table>
</form>
y el codigo de ejecucion es
Código PHP:
<?php
// Preguntaremos si se han enviado ya las variables necesarias
if ($_POST) {
include('config.ini.php');
echo '<tr><td width="1329" height="2">';
/////////////////////////////////////////////
$conn=mysql_connect ($info['host'],$info['user'],$info['pass'])or die("Error3:<br>".mysql_error());
mysql_select_db($info['bd'],$conn)or die("Error1:<br>".mysql_error());
/////////////////////////////////////////////
$username = $_POST["nick"];
$password = $_POST["clave"];
$cpassword = $_POST["cpclave"];
$email = $_POST["email"];
$nom = $_POST["nom"];
$cognom = $_POST["cognom"];
$nuevoNombre = $_POST["foto"];
$telf= $_POST["telf"];
$CP= $_POST["CP"];
$domicili= $_POST["domicili"];
$dni= $_POST["dni"];
// Hay campos en blanco
if($username==NULL|$password==NULL|$cpassword==NULL|$email==NULL|$dni==NULL|$telf==NULL|$nom==NULL|$cognom==NULL) {
echo "Hi han caselles buides.";
}else{
// ¿Coinciden las contraseñas?
if($password!=$cpassword) {
echo "Las clave no coinciden";
}else{
// Comprobamos si el nombre de usuario o la cuenta de correo ya existían
$checkuser = mysql_query("SELECT * FROM ".$info['table2']." WHERE nick='$username'");
$username_exist = mysql_num_rows($checkuser);
$checkemail = mysql_query("SELECT * FROM ".$info['table2']." WHERE email='$email'");
$email_exist = mysql_num_rows($checkemail);
if ($email_exist>0|$username_exist>0) {
echo "<font color=red><h4>Algú altre ja ha registrat una compte amb el mateix Nic o el matiex correu electrònic.</h4></font>";
}else{
//Todo parece correcto procedemos con la inserccion
if(isset($submit)){
if (is_uploaded_file($_FILES['imagen']['tmp_name'])) {
//revisar que sea jpg
if ($_FILES['imagen']['type'] == "image/jpeg" || $_FILES['imagen']['type'] == "image/pjpeg"){
//nuevo nombre para la imagen
$nuevoNombre = time().".jpg";
//mover la imagen
move_uploaded_file($_FILES['imagen']['tmp_name'], "foto/$nuevoNombre");
//obtener la inforamción
$data = GetImageSize("foto/$nuevoNombre");
}else{
echo "Format de la imatge no válid.";
}
} else {
echo "<font color=red><b>El sistema no troba la imatge reinicia el registre.</b></font> " . $_FILES['imagen']['name'];
}
}
$query = "INSERT INTO ".$info['table2']." (nick, clave, email, nivel, puntos, nom, cognom, foto, telf, CP, domicili, dni) VALUES('$username','$password','$email', '1','0','$nom','$cognom','$nuevoNombre','$telf','$CP','$domicili','$dni')";
mysql_query($query) or die(mysql_error());
echo "<font color=green><h4>L'usuari $username s'ha registrat correctament.</h4></font>";
}
}
}
echo '</td></tr>';
}
?>
Subir todos los datos en el formulario en la base de datos subir la imagen a una carpeta y guardar el nombre en la base de datos.
en el localhost me sirve y funciona perfectamente pero en el servidor de pago STRATO no funciona! sube toda la informacion y en el campo donde pone foto esta vacio!
Ayuda por favor!