Foros del Web » Programando para Internet » PHP »

Sistema de registro con avatar

Estas en el tema de Sistema de registro con avatar en el foro de PHP en Foros del Web. Buenas, quisiera que me ayuden tengo un sistema de registro pero quiera añadir para que suban su foto. ejemplo Registro de usuarios: NOMBRE: USUARIO123 CONTRASEÑA: ...
  #1 (permalink)  
Antiguo 21/06/2010, 23:50
 
Fecha de Ingreso: agosto-2009
Mensajes: 85
Antigüedad: 14 años, 8 meses
Puntos: 1
Pregunta Sistema de registro con avatar

Buenas, quisiera que me ayuden tengo un sistema de registro pero quiera añadir para que suban su foto. ejemplo

Registro de usuarios:

NOMBRE: USUARIO123
CONTRASEÑA: 13456
REPETIR CONTRASEÑA: 13456
PAIS: PERU
FECHA DE NACIMIENTEO: 12/235/1295
FOTO: EXAMINAR

Asi mi regitro tengo en la parte de foto para poner url pero hay algunos usuarios que no saven mucho de url y ponen otras cosas, bueno para evitar ese tipo de problemas que agregar un detatelle para suba la foto y el url de la foto se guarde en mi base de datos. este es el codigo de mi registro:


Código PHP:
Ver original
  1. <?php
  2.  
  3. // Registro de usuarios
  4. // CopyLeft 2007 // ziin razoon
  5. // Registro.php
  6. // Creado: 22-3-05
  7.  
  8. include("config.php");
  9. if($_POST['registro']){
  10.  
  11. include("config.php");
  12. function html($texto) {
  13. $texto = trim($texto) ;
  14. $texto = htmlspecialchars($texto) ;
  15. return $texto ;
  16. }
  17.  
  18. if($_POST[contrasena]==$_POST[contrasena2]){
  19.  
  20. $query = mysql_query("SELECT * FROM usuarios WHERE nick='$_POST[nick]' or email='$_POST[email]'");
  21. if(mysql_num_rows($query)==0){
  22.  
  23. if(!$_POST[nick]){ $error = _ERROR_NICK_; }
  24. if(!$_POST[contrasena]){ $error = _ERROR_PASS_; }
  25. if(!$_POST[email]){ $error = _ERROR_EMAIL_; }
  26.  
  27. $fecha = time();
  28. $nick = html($_POST[nick]);
  29. $contrasena = md5($_POST[contrasena]);
  30. $MailPass = $_POST[contrasena2];
  31. $email = html($_POST[email]);
  32. $avatar = html($_POST[avatar]);
  33. $nombre = html($_POST[nombre]);
  34. $pais = html($_POST[pais]);
  35. $sexo = html($_POST[sexo]);
  36. $boletin = html($_POST[boletin]);
  37. $ip = $REMOTE_ADDR;
  38. $n_dia = html($_POST[n_dia]);
  39. $n_mes = html($_POST[n_mes]);
  40. $n_ano = html($_POST[n_ano]);
  41.  
  42. } else {
  43.  $error = _YA_REGISTRADOS_;
  44.  }
  45. } else {
  46.  $error = _ALERTA_CONTRASENA_;
  47.  }
  48.  
  49. if($error){ echo"<script>alert('"._ERROR_P_." ".$error."'); window.location='javascript:history.back()';</script>"; } else {
  50. $infp = mysql_query("SELECT * FROM configuracion");
  51. $info = mysql_fetch_array($infp);
  52. $puntos = $info[preg];
  53.  
  54. if(!mysql_query("INSERT INTO usuarios (nick,contrasena,email,fecha,avatar,nombre,pais,sexo,boletin,ip,conectado,puntos,n_dia,n_mes,n_ano) VALUES ('$nick','$contrasena','$email','$fecha','$avatar','$nombre','$pais','$sexo','$boletin','$ip','$fecha','$puntos','$n_dia','$n_mes','$n_ano')")){
  55.     echo"<script>alert('"._ERROR_P_." "._ERROR_QUERY_."'); window.location='javascript:history.back()';</script>";
  56. }
  57.  
  58. echo"<script>location='http://miweb.com/web/?nick=$nick'</script>";
  59. }
  60.  
  61. } else {
  62.  
  63.  
  64. ?>
  65. <form action="<?=$pagina?>?<?=$get?>=registro" method="post"><table width="99%"  border="0" align="center" cellpadding="3" cellspacing="0">
  66.   <tr>
  67.     <td width="17%">NICK</td>
  68.     <td width="83%">
  69.       <input name="nick" type="text" id="nick">
  70.       <span style="color:#990000">*</span> </td>
  71.   </tr>
  72.   <tr>
  73.     <td>CONTRASEÑA</td>
  74.     <td>
  75.       <input name="contrasena" type="password" id="contrasena">
  76.      <span style="color:#990000">*</span></td>
  77.   </tr>
  78.   <tr>
  79.     <td>REPITELO</td>
  80.     <td>
  81.       <input name="contrasena2" type="password" id="contrasena2">
  82.       <span style="color:#990000">*</span></td>
  83.   </tr>
  84.   <tr>
  85.     <td>EMAIL</td>
  86.     <td>
  87.       <input name="email" type="text" id="email">
  88.         <span style="color:#990000">*</span></td>
  89.   </tr>
  90.   <tr>
  91.     <td>FOTO</td>
  92.     <td>
  93.      <input name="avatar" type="text" id="avatar" value="Ingresa el url de tu foto" >
  94.      <span style="color:#990000">*</span>   </td>
  95.   </tr>
  96.   <tr>
  97.     <td>NOMBRE</td>
  98.     <td>
  99.        <input name="nombre" type="text" id="nombre" ></td>
  100.   </tr>
  101.   <tr>
  102.     <td>SEXO</td>
  103.     <td>
  104.       <select name="sexo" id="sexo">
  105.         <option value="0">Masculino</option>
  106.         <option value="1">Femenino</option>
  107.       </select>    </td>
  108.   </tr>
  109.   <tr>
  110.     <td>PASI</td>
  111.     <td>
  112.       <input name="pais" type="text"  id="pais">    </td>
  113.   </tr>
  114.   <tr>
  115.     <td>RESEVIR BOLETIN </td>
  116.     <td><input name="boletin" type="radio" value="si" checked>
  117.      SI
  118.         <input name="boletin" type="radio" value="no">
  119.       NO</td>
  120.   </tr>
  121.   <tr>
  122.     <td colspan="2" class="input">&nbsp;</td>
  123.   </tr>
  124.   <tr>
  125.     <td height="32"></td>
  126.     <td>
  127.       <input name="registro" type="submit" id="registro" value="<?=_REG_REGISTRAR_?>">
  128.       <input name="borrar" type="reset" id="borrar" value="<?=_REG_BORRAR_?>">    </td>
  129.   </tr>
  130.   <tr>
  131.     <td colspan="2"><font size="1" face="Georgia, Times New Roman, Times, serif">(*) <?=_REG_OB_?> </font></td>
  132.   </tr>
  133. </table>
  134. </form>
  135. <?
  136.  
  137. }
  138.  
  139. ?>

Y este codigo me permite subir imagenes ami web funciona perfectamente:


Código PHP:
Ver original
  1. <?  
  2. if($_POST){
  3. // Creamos la cadena aletoria
  4. $str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
  5. $cad = "";
  6. for($i=0;$i<12;$i++) {
  7. $cad .= substr($str,rand(0,62),1);
  8. }
  9. // Fin de la creacion de la cadena aletoria
  10. $tamano = $_FILES [ 'file' ][ 'size' ]; // Leemos el tamaqo del fichero
  11. $tamaqo_max="50000000000"; // Tamaqo maximo permitido
  12. if( $tamano < $tamaqo_max){ // Comprovamos el tamaqo  
  13. $destino = 'uploaded' ; // Carpeta donde se guardata
  14. $sep=explode('image/',$_FILES["file"]["type"]); // Separamos image/
  15. $tipo=$sep[1]; // Optenemos el tipo de imagen que es
  16. if($tipo == "gif" || $tipo == "pjpeg" || $tipo == "bmp"){ // Si el tipo de imagen a subir es el mismo de los permitidos, segimos. Puedes agregar mas tipos de imagen
  17. move_uploaded_file ( $_FILES [ 'file' ][ 'tmp_name' ], $destino . '/' .$cad.'.'.$tipo);  // Subimos el archivo
  18. include('post.html'); // Incluimos la plantilla
  19. }
  20. else echo "el tipo de archivo no es de los permitidos";// Si no es el tipo permitido lo desimos
  21. }
  22. else echo "El archivo supera el peso permitido.";// Si supera el tamaqo de permitido lo desimos
  23. }
  24. ?>

Ahora lo que quiero es unirlo los codigos alguien me podria ayudar por favor.

Última edición por ziin; 24/06/2010 a las 19:27

Etiquetas: avatar, registro, sitemap
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:24.