Ver Mensaje Individual
  #13 (permalink)  
Antiguo 09/10/2009, 16:55
samu22
 
Fecha de Ingreso: abril-2008
Mensajes: 453
Antigüedad: 16 años, 1 mes
Puntos: 16
Respuesta: ayuda con este script y los array

te esta llegando valor por get?, otra cosa mas porque guardas $name[], en otro array, no hace falta, te lo reescribo como deberia quedarte

Código php:
Ver original
  1. $username = $_GET['username'];
  2.  
  3. if (usernameExists($username)) {
  4.   echo '<span style="color:red";>Username Taken</span>';
  5. }
  6. else {
  7.   echo '<span style="color:green;">Username Available</span>';
  8. }
  9.  
  10. function usernameExists($input) {
  11. $conn = mysql_connect("localhost", "root", "mi password") or die(mysql_error());
  12. mysql_select_db("mibd", $conn) or die(mysql_error());
  13.  
  14. $sql = "SELECT nombre FROM usuarios";
  15. $query = mysql_query($sql);
  16. while($ver = mysql_fetch_assoc($query)) {
  17.  
  18. $user[]=$ver['nombre'];
  19.  
  20. }
  21.  
  22.   if (in_array($input, $user)) {
  23.     return true;
  24.   }
  25.   else {
  26.     return false;
  27.   }
  28.   }

si no te esta tomando con esto es porque $_GET['username'] esta llegando vacia