Ver Mensaje Individual
  #4 (permalink)  
Antiguo 12/10/2005, 13:30
Avatar de disenopop
disenopop
 
Fecha de Ingreso: septiembre-2005
Mensajes: 10
Antigüedad: 18 años, 7 meses
Puntos: 0
Pregunta

Ok...

Realicé algunas pruebas sin éxito...

He implementado algo que efectivamente muestra el radiobutton seleccionado después de dar submit, pero siempre se muestra el último (supongo que es alguna cuestión con los if...else if)

Se puede ver el formulario funcionando en
http://demos.intermexico.net/mhv/form.htm

aqui la muestra del código:

Código PHP:
<html><head><title>Formulario de contacto</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body>
<?
if($enviar=="Enviar"){
//VERIFICAR CAMPOS
    
if((isset($_POST['nombre']))&&(($_POST['nombre'])=="")){
        echo 
"<p style='color:#FF0000;'><b>Ingrese su Nombre</b></p>"
    }else if ((isset(
$_POST['email']))&&(($_POST['email'])=="")){
        echo 
"<p style='color:#FF0000;'><b>Ingrese su E-Mail</b></p>"
    }else if (empty(
$_POST['servicio'])){
        echo 
"<p style='color:#FF0000;'><b>Especifique Servicio</b></p>";
    }else{
        require 
"includes/class.phpmailer.php";
        
$mail = new phpmailer();
        
$mail->PluginDir "includes/";
        
$mail->ContentType "text/html";
        
$mail->Mailer "smtp";
        
$mail->Host "mail.mydominio.net";
        
$mail->SMTPAuth false;
        
$mail->From "$email";
        
$mail->FromName "$nombre";
        
$mail->Timeout=50;
        
$mail->AddAddress("[email protected]");
        
$mail->Subject "Nuevo Mensaje";
        
$mail->Body "
        <div style='padding:30px;'><h3>Nuevo mensaje</h3>
        <p><b>Nombre:</b> $nombre</p>
        <p><b>E-mail:</b> $email</p>
        <p><b>Servicios:</b> $servicio</p>
        </div>
        "
;
        
$exito $mail->Send();        
        if(!
$exito){
            echo 
"<br>".$mail->ErrorInfo;    
           } else {
            
$bandera "true";
           } 
    }
}
if(
$bandera=="true"){
    echo 
"<h3>Su mensaje ha sido enviado</h3>";
}
else{
?>
<fieldset style="width:300px;"><legend>Formulario de contacto</legend><form name="form1" method="post" action="">
<table width=300 border=0 cellspacing=0 cellpadding=5>
  <tr>
    <td align=right><label>Nombre: </label></td>
    <td><input type="text" name="nombre" value="<? echo $nombre ?>"></td>
  </tr>
  <tr>
    <td align=right><label>E-mail: </label></td>
    <td><input type="text" name="email" value="<? echo $email ?>"></td>
  </tr>
  <tr>
    <td align=right>Servicios:</td>
    <td>
    <?
// Aqui la parte implementada
    
if (empty($_POST['servicio'])){
        echo 
"<input name='servicio' type='radio' value='servicio1'>";
    }else if(isset(
$_POST['servicio'])){
        echo 
"<input name='servicio' type='radio' value='servicio1' checked>";
    }
    
?>
    <label>Servicio 1</label><br>
    <?
// Aqui la parte implementada
    
if (empty($_POST['servicio'])){
        echo 
"<input name='servicio' type='radio' value='servicio2'>";
    }else if(isset(
$_POST['servicio'])){
        echo 
"<input name='servicio' type='radio' value='servicio2' checked>";
    }
    
?>
    <label>Servicio 2</label><br>
    <?
// Aqui la parte implementada
    
if (empty($_POST['servicio'])){
        echo 
"<input name='servicio' type='radio' value='servicio3'>";
    }else if(isset(
$_POST['servicio'])){
        echo 
"<input name='servicio' type='radio' value='servicio3' checked>";
    }
    
?>
    <label>Servicio 3</label><br>
    <?
// Aqui la parte implementada
    
if (empty($_POST['servicio'])){
        echo 
"<input name='servicio' type='radio' value='servicio4'>";
    }else if(isset(
$_POST['servicio'])){
        echo 
"<input name='servicio' type='radio' value='servicio4' checked>";
    }
    
?>
    <label>Servicio 4</label>
    </td>
  </tr>
  <tr>
    <td align=right>&nbsp;</td>
    <td><input type="submit" name="enviar" value="Enviar"></td>
  </tr>
</table>
</form></fieldset>
<? ?>
</body></html>
Alguna sugerencia please?...