Ver Mensaje Individual
  #9 (permalink)  
Antiguo 23/04/2016, 05:42
Avatar de Juan_Enrique
Juan_Enrique
 
Fecha de Ingreso: abril-2016
Ubicación: Jerez de la Frontera, Cádiz. España
Mensajes: 6
Antigüedad: 8 años
Puntos: 0
Respuesta: pasar variables de html a php

Hola! Espero poder ayudarte.

Voy a poner tu código haciéndole comentarios para que veas donde veo yo los fallos

Pagina 1:
Código HTML:
<!doctype html>
<html lang=''>
<head>
   <meta charset='utf-8'>
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
   <meta name="viewport" content="width=device-width, initial-scale=1">
   <link rel="stylesheet" href="styles.css">
   <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
   <script src="script.js"></script>   
  
</head>
<body>
 
<div>
<h5>SERIE</h5>
<form name="serie" id="serie" method="post" action="pagina2.php">
<table width="294" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="20" height="22">
      <label><input type="radio" name="radio2" id="radio2" value="OPCION1"></label>
    </td>
    <td width="274"><h6 style="margin:0;">OPCION1</h6></td>
  </tr>
  <tr>
    <td height="22">
      <label><input type="radio" name="radio2" id="radio2" value="OPCION2"></label> <!-- Este radio button tiene el mismo id que el primero -->
    </td>
    <td><h6 style="margin:0;">OPCION2</h6></td>
  </tr>
</table>
<br>
<CENTER><input type="image" src="images/sig.png" name="submit" value="Enviar"></CENTER> <!-- No se muy bien que quieres hacer aquí. Pero para pasar los datos por post el tipo del input debería ser submit no image como tienes puesto -->
</form>
</div>
 
</body>
<html> 
Página 2
Código PHP:
<!doctype html>
<html lang=''>
<head>
   <meta charset='utf-8'>
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
   <meta name="viewport" content="width=device-width, initial-scale=1">
   <link rel="stylesheet" href="styles.css">
   <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
   <script src="script.js"></script>
  
<?php
 
session_start
();
$_SESSION['radio2'] = $_POST['radio2'];  /* Ojo con esto, esta bien, pero quiero que la tengas en cuenta para la página 3 */
?>  
</head>
<body>
 
<form name="serie" id="serie" method="post" action="pagina3.php">
 
<table width="294" border="0">
  <tr>
    <td width="54"><h6 style="margin:0;">Nombre:</h6></td>
    <td width="224"><input name="nombre" type="text" id="nombre" style="background-color:#CCCCCC" size="25" maxlength="30" required/></td>
  </tr>
  <tr>
    <td><h6 style="margin:0;">Apellido:</h6></td>
    <td><input name="apellido" type="text" id="apellido" style="background-color:#CCCCCC" size="25" maxlength="30" required/></td>
  </tr>
  <tr>
    <td><h6 style="margin:0;">Tlf:</h6></td>
    <td><input name="tlf" type="text" id="tlf" style="background-color:#CCCCCC" size="25" maxlength="15" required/></td>
  </tr>
  <tr>
    <td><h6 style="margin:0;">Email:</h6></td>
    <td><input name="mail" type="text" id="mail" style="background-color:#CCCCCC" size="25" required/></td>
  </tr>
</table><br>  
<center>
<input type="image" src="images/sig.png" name="submit" value="Enviar">  <!-- de nuevo esto yo lo pondria como type input -->
</center>
</form>
 
 
</body>
<html>
Página 3
Código PHP:
<?php
session_start
();
$_SESSION['radio2'] = $_POST['radio2']; /*Aqui estas pisando el valor que tenia $_SESSION['radio2'] por un valor que no existe ya que radio2 no existe en la pagina 2 con lo cual $_POST['radio2'] no es nada*/
$opcion $_POST['radio2']; /* Aqui de nuevo estas utilizando $_POST['radio2'] y como he dicho antes no tiene ningun valor*/
$opcion2 $_POST['opcion'];/*en la pagina 2 no hay ningun input que sea opcion con lo cual esto estara vacio*/
$opcion4 $_SESSION['radio2'];/* Al haber pisado la variable $_SESSION['radio2'], la cual no tiene valor ahora mismo, $opcion4 tampoco tendra valor*/
$nombre $_POST['nombre'];
$apellido $_POST['apellido'];
$tlf $_POST['tlf'];
$mail $_POST['mail'];
$header 'From: ' $mail " \r\n";
$header .= "X-Mailer: PHP/" phpversion() . " \r\n";
$header .= "Mime-Version: 1.0 \r\n";
$header .= "Content-Type: text/plain";
$mensaje .= "SELECCIÓN DEL CHECKBOX: " $_SESSION['radio2'] . " \r\n\n";/*$_SESSION['radio2'] no tiene valor*/
$mensaje .= "Este mensaje fue enviado por: \r\n\n";
$mensaje .= "Nombre: " $nombre " \r\n";
$mensaje .= "Apellido: " $apellido " \r\n";
$mensaje .= "Telefono: " $tlf " \r\n";
$mensaje .= "Su e-mail es: " $mail " \r\n";
$mensaje .= "Enviado el: " date('d/m/Y'time());
 
$para '[email protected],[email protected]';
$asunto 'SOLICITUD';
 
mail($para$asuntoutf8_decode($mensaje), $header);
echo 
"<script>document.location.href='index.html';</script>\n";   
 
?>