
como llamar al post['?']
Publicado por alejandro (15 intervenciones) el 09/08/2017 00:04:09
encuesta.php
enviarencuesta.php
Mi duda es q $p1=$_POST['$likert']; el $likert quizas lo estoy llamando mal porque no me llama a nada y me sale el error del echo
de antemano gracias
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="../css/bootstrap.min.css">
<link rel="stylesheet" href="../css/eventos2.css">
</head>
<body>
<?php
include("conexion.php");
date_default_timezone_set("America/Santiago");
$consulta = "SELECT * FROM tabla_demo";
mysql_query("SET NAMES 'utf8'");
//Ejecutar la consulta
$resultado = mysqli_query($conexion,$consulta);
?>
<div class="row">
<form action="enviarencuesta.php" method="post">
<tr id="escala">
<th><p>Pregunta</p></th>
<th><p>No aplica</p></th>
<th><p>Muy en desacuerdo</p></th>
<th><p>En desacuerdo</p></th>
<th><p>En Acuerdo</p></th>
<th><p>Muy de acuerdo</p></th>
</tr>
<?php
$likert=1;
while ($row = mysqli_fetch_array($resultado)){
echo "<div class='col-md-8'>";
echo "<td>".$row['nombres']."</td>";
echo "</div>";
echo "<div class='col-md-4'>";
echo "<input type='radio' name='$likert' value='no aplica' required>";
echo "<input type='radio' name='$likert' value='muy en desacuardo' required>";
echo "<input type='radio' name='$likert' value='en desacuerdo' required>";
echo "<input type='radio' name='$likert' value='en acuerdo' required>";
echo "<input type='radio' name='$likert' value='muy de acuerdo' required>";
echo "</div>";
$likert=$likert + 1;
}
?>
<button type="submit" name="">enviar</button>
</form>
</div>
<script src="../js/jquery.js"></script>
<script src="../js/bootstrap.min.js"></script>
</body>
</html>
enviarencuesta.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
$host="localhost";
$usuario="root";
$pass="";
$bd ="pruebas";
$conexion = mysqli_connect($host,$usuario,$pass,$bd);
// Get values from form
$p1=$_POST['$likert'];
// Insert data into mysql
$sql="INSERT INTO respuesta(tipo_respuesta)VALUES('$p1')";
$result=mysqli_query($conexion,$sql);
// if successfully insert data into database, displays message "Successful".
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='index.php'>Back to main page</a>";
}
else {
echo "ERROR";
}
?>
<?php
// close connection
mysqli_close($conexion);
?>
Mi duda es q $p1=$_POST['$likert']; el $likert quizas lo estoy llamando mal porque no me llama a nada y me sale el error del echo
de antemano gracias
Valora esta pregunta


0