Foros del Web » Programando para Internet » PHP »

Php ayuda

Estas en el tema de Php ayuda en el foro de PHP en Foros del Web. Hola estoy haciendo una pagian web que tine un cuadro para escribir un email y un boton para enviarlo a un base de datos. Pero ...
  #1 (permalink)  
Antiguo 30/10/2009, 15:13
Raftuz
Invitado
 
Mensajes: n/a
Puntos:
Php ayuda

Hola estoy haciendo una pagian web que tine un cuadro para escribir un email y un boton para enviarlo a un base de datos.
Pero el prbelma esque no me envia los datos a la bd lo estoy probando en localhost con xamp.

Aqui pego el codigo
Código PHP:
<?php

$bd
=mysql_connect ("localhost","root","") or die ("No puedo conectarme");
mysql_select_db("b18_4386695_emails");

$opt=$HTTP_GET_VARS["opt"];

if (
$opt==1)
{
  
$Correo=$HTTP_GET_VARS["Correo"];
   
  
$sql="insert into correo (Email) values (' ".$Email." ')";
  
$res=mysql_query($sql,$bd) or die (mysql_error ());
}

?>

<html>
<head>
<title>Documento sin título</title>
</head>

<script language="javascript">
function verifica ()
{
  if (form1.Correo.value=="")
    {
      alert ("Ingrese su email");
      return;
   }
 form1.opt.value=1;
 form1.submit(); 
}
</script>


<body>
<form id="form1" name="form1" method="get" action="">
<input type="hidden" name="opt"
  <p>Correo Electronico: 
    <label for="Correo"></label>
  <input type="text" name="Correo" id="Correo" />
  </p>
  <p>
    <label for="Enviar"></label>
    <input type="submit" name="Enviar" id="Enviar"  value="Enviar" onclick=verifica()>
  </p>
</form>
</body>
</html>
  #2 (permalink)  
Antiguo 30/10/2009, 15:21
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: Php ayuda

usar $HTTP_*_VARS es obsoleto... en su lugar usa $_GET, $_POST, etc, respectivamente...


suerte!!
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #3 (permalink)  
Antiguo 30/10/2009, 15:31
Avatar de dcreate  
Fecha de Ingreso: octubre-2009
Ubicación: Veracruz
Mensajes: 536
Antigüedad: 14 años, 6 meses
Puntos: 22
Respuesta: Php ayuda

yo opino q deberia ser asi

Cita:
$Correo=$_POST["Correo"];
  #4 (permalink)  
Antiguo 30/10/2009, 15:32
Avatar de dcreate  
Fecha de Ingreso: octubre-2009
Ubicación: Veracruz
Mensajes: 536
Antigüedad: 14 años, 6 meses
Puntos: 22
Respuesta: Php ayuda

y el query asi:

$sql="insert into correo (Email) values ('$Correo')";
  #5 (permalink)  
Antiguo 31/10/2009, 02:45
Raftuz
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: Php ayuda

Sique sin funcionar
Código PHP:
<?php

$bd
=mysql_connect ("localhost","root"," ") or die ("No puedo conectarme");
mysql_select_db("b18_4386695_emails");

$opt=$_POST["opt"];

if (
$opt==1)
{
  
$Correo=$_POST["Correo"];
   
  
$sql="insert into correo (Emails) values ('$Correo')";
  
$res=mysql_query($sql,$bd) or die (mysql_error ());
}

?>

<html>
<head>
<title>Documento sin título</title>
</head>

<script language="javascript">
function verifica ()
{
  if (form1.Correo.value=="")
    {
      alert ("Ingrese su email");
      return;
   }
 form1.opt.value=1;
 form1.submit(); 
}
</script>


<body>
<form id="form1" name="form1" method="post" action="">
<input type="hidden" name="opt"
  <p>Correo Electronico: 
    <label for="Correo"></label>
  <input type="text" name="Correo" id="Correo" />
  </p>
  <p>
    <label for="Enviar"></label>
    <input type="submit" name="Enviar" id="Enviar"  value="Enviar" onclick=verifica()>
  </p>
</form>
</body>
</html>
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 11:43.