Ver Mensaje Individual
  #11 (permalink)  
Antiguo 31/10/2008, 12:41
jesusjj
 
Fecha de Ingreso: noviembre-2007
Mensajes: 154
Antigüedad: 16 años, 6 meses
Puntos: 2
Respuesta: Problema con 'foreach'

Buenas, copio toda la parte del rollo, sigue sin funcionar.

Código PHP:
# -> Creación de varibles de formulario

/*function VariablesFormulario () {
    foreach ($_POST as $campo => $valor) {
        $asignacion = "$" . $campo . "='" . $valor . "';";
        eval($asignacion); 
    }
}*/

      function VariablesFormulario ($auxDatos) {
          foreach ($auxDatos as $campo => $valor)
              $GLOBALS[$campo] = $valor;
      }



# -> Creación de formulario de contacto

function do_form_contacto() {
?>
    <form id="contacto" action="index.php?pag=9&contacto=envio&tipo=0" method="post" name="f_consulta" onsubmit="return formValidation()">
        <fieldset>
            <img class='f_right' src='img/srta.jpg' alt='consulta' height="150px" />
            <legend>Información de contacto</legend>
            <label for="nombre">Nombre:</label>
            <input type="text" name="nombre" /><br />
            <label for="apellidos">Apellidos:</label>
            <input type="text" name="apellidos" />
            <label for="empresa">Empresa:</label>
            <input type="text" name="empresa" />
            <label for="mail">Mail:</label>
            <input type="text" name="mail" />            
        </fieldset>
        <fieldset>
            <legend>Consulta</legend>
            <textarea id="consulta" name="consulta"></textarea>
        </fieldset>
        
        <input type="submit" value="enviar" />
        <input type="reset" value="borrar" />
    </form>
<?php
}

# -> Envío formulario

function envio_formulario () {
    
$tipo $_GET['tipo'];
    
    
$para "####";    
    
    if (
$tipo == 1) { // caso compra
        
VariablesFormulario();
        
    }else{ 
// caso consulta


        
VariablesFormulario($_POST);


        
$asunto "Consulta WEB";
        
$mensaje "<span class='producto'>Nombre: </span>" .$nombre"<br />";
        
$mensaje .=    "<span class='producto'>Apellidos: </span>" .$apellidos"<br />";
        
$mensaje .= "<span class='producto'>Empresa: </span>" .$empresa"<br />";
        
$mensaje .= "<span class='producto'>Mail: </span><a href='mailto:".$mail."'>" .$mail"</a><br />";
        
$mensaje .= "<span class='producto'>Consulta: </span>" .$consulta"<br />";
    
        echo 
$mensaje;
                
//        mail($para, $asunto, $mensaje, $headers);
//        Header("Location:index.php?pag=9&contacto=confirma");
//        exit();
    
}

}