Ver Mensaje Individual
  #6 (permalink)  
Antiguo 22/01/2013, 09:09
Avatar de andresdzphp
andresdzphp
Colaborador
 
Fecha de Ingreso: julio-2011
Ubicación: $this->Colombia;
Mensajes: 2.749
Antigüedad: 12 años, 10 meses
Puntos: 793
Respuesta: MySQL query con variables PHP

Algo así:

Código PHP:
Ver original
  1. <?php
  2.  
  3. //MySQL Database Connect
  4. mysql_connect("localhost", "*******", "*********")  or die("Unable to connect to MySQL");
  5. mysql_select_db('tu_base_de_datos_aqui');
  6.  
  7. //get data from form  
  8. $email=$_POST['email'];
  9.  
  10. //Count coincidences on database
  11. $sql = "SELECT COUNT(*) existe FROM pressmails WHERE email='$email'";
  12. $result = mysql_query($sql) or die (mysql_error());
  13. $reg = mysql_fetch_assoc($result);
  14.  
  15. //If there are more than 0 coincidences the user is registered  
  16. //otherwise not registered
  17. if($reg['existe']){  
  18.     echo "The user is registered";
  19. } else {  
  20.     echo "The user is not registered";
  21. }  
  22.  
  23. //Close database connection
__________________
Si sabemos como leer e interpretar el manual será mucho más fácil aprender PHP. En lugar de confiar en ejemplos o copiar y pegar - PHP