PHP - funcion no imprime el resultado

 
Vista:
sin imagen de perfil
Val: 107
Ha disminuido 1 puesto en PHP (en relación al último mes)
Gráfica de PHP

funcion no imprime el resultado

Publicado por Joseba (56 intervenciones) el 27/10/2018 19:38:18
Aupa , mi problema.. , tengo tres achivos en PHP , uno el que uso como Web formular y se llama ,

index4.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
<?php
 include 'ClassProveContakt3.php';
 header('Content-Type: text/html; Charset=utf-8');
 mb_internal_encoding('UTF-8');
 date_default_timezone_set('Europe/Paris');
 error_reporting(-1);
 error_reporting(E_ALL);
 
 
$ProveContackt=new ClassProveContakt3;
?>
 
 
<!DOCTYPE html>
<html lang="en_mx">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
 
   <form name="form" id="form" method="POST" action="index4.php" >
 
<?php
 
     $ProveContackt->GetPostData();
 
     $ProveContackt->form();
 
     $ProveContackt->PostOk();
 
?>
 
</form>
</body>
</html>

Un archivo donde guarda el resultado y al vez es donde lleva de vuelta los resultado a index4.php y se llama test.txt .


y segundo que es donde esta el PHP code y donde creo que esta el problema.. y se llama ClassProveContakt3.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
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?php
 
header('Content-Type: text/html; Charset=utf-8');
mb_internal_encoding('UTF-8');
date_default_timezone_set('Europe/Paris');
error_reporting(E_ALL);
 
 
class ClassProveContakt3
{
 
      private $Name;
      private $Email;
      private $Message;
 
 
    function __construct()
    {
 
        $this->Name="";
        $this->Email="";
        $this->Message="";
 
    }
 
 
     function Form()
     {
 
        echo('<table>');
 
                    echo('<label for="name">Name </label>');
                    echo('<input type="text" name="Name" value="'.$this->Name.'">');
                    echo('<label for="email"> E-mail </label>');
                    echo('<input type="email" value="'.$this->Email.'" name="Email" ');
              echo('<tr>');
 
 
 
                 echo('<td>');
                     echo('<br>');
                     echo('<label> Message: <br><textarea cols="45" rows="6" name="Message">'.$this->Message.'</textarea></label>');
                     echo('<br><br>');
                     echo('<input  type="submit" name="post" value="POST COMMENT" id="comment">');
 
                 echo('</td>');
 
              echo('</tr>');
 
         echo('</table>');
 
      }
 
      function GetPostData()
      {
 
          if(isset($_POST["Name"]) && isset($_POST["Email"]) && isset($_POST["Message"]))
           {
                $this->Name = trim(filter_input( INPUT_POST, 'Name', FILTER_SANITIZE_STRING));
                $this->Email = trim(filter_input( INPUT_POST, 'Email', FILTER_SANITIZE_STRING));
                $this->Message = trim(filter_input( INPUT_POST, 'Message', FILTER_SANITIZE_STRING));
           }
 
      }
 
      function PostOk()
      {
 
               if (!isset($_POST['post']))
               {
 
                  return;
               }
                   if (empty($this->Name) ||  empty($this->Email) || empty($this->Message))
                   {
 
                       echo "<br>" . "<b>" . "<h3>*** Please enter all required fields ***</h3>" . "</b>";
 
                   }
 
                   else
                   {
 
                       $file = "test.txt";
 
                       $name = filter_input( INPUT_POST, 'Name', FILTER_SANITIZE_STRING);
                       $email = filter_input(INPUT_POST, 'Email', FILTER_SANITIZE_STRING);
                       $message = filter_input(INPUT_POST, 'Message', FILTER_SANITIZE_STRING);
                       $datetime = date('m/d/Y h:i:s a', time());
 
                       $data = array("name" => $name, "email" => $email, "message" => $message, "datetime" => $datetime);
 
	           $data = serialize($data);
	              file_put_contents($file, $data . "\n", FILE_APPEND|LOCK_EX);
 
                       $messages = file($file);
 
    		              foreach ($messages as $value) {
    		                $data = unserialize($value);
 
                                  echo "<br>"
 
                                      . "<b>From: </b>" . htmlspecialchars( $data["name"])
                                      . "<b> at: </b>" . htmlspecialchars( $data["datetime"])
                                      . "<br><br>" . htmlspecialchars( $data["email"])
                                      . "<br><br>" . htmlspecialchars( $data["message"])
                                      . "<br><hr>";
 
                       }
 
                    }
 
        }
 
 
        function mella ()
       {
              if(isset($_POST["Name"]) && isset($_POST["Email"]) && isset($_POST["Message"]))
              {
 
              }
 
                 echo "<table border='1'>";
                 echo "<tr><td><b>Name</b></td><td><b>Email</b></td><td><b>Message</b></td><td><b>datetime</b></td>";
                 echo "</tr>";
 
 
                 $name = filter_input( INPUT_POST, 'Name', FILTER_SANITIZE_STRING);
                 $email = filter_input(INPUT_POST, 'Email', FILTER_SANITIZE_STRING);
                 $message = filter_input(INPUT_POST, 'Message', FILTER_SANITIZE_STRING);
                 $datetime = date('m/d/Y h:i:s a', time());
 
 
                 $datas = array("name" => $name, "email" => $email, "message" => $message, "datetime" => $datetime);
 
		     foreach ($datas as $key => $value)
		     {
                  echo "<tr><td>$name</td><td>$email</td><td>$message</td><td>$datetime</td>";
 
		  	    if(isset($_POST["form"] [$key]))
    			       {
    			      	echo"<td>" . htmlspecialchar($value["name"]) . "</td>";
    			      	echo"<td>" . htmlspecialchar($value["email"]) . "</td>";
    			      	echo"<td>" . htmlspecialchar($value["message"]) . "</td>";
    			      	echo"<td>" . htmlspecialchar($value["datetime"]) . "</td>";
                     echo "</tr>";
 
                   }
                }
                echo "</table>";
 
         }
 
}
?>


en este archivo todas las funciones funcionan bien , menos la ultima , function mella () quiero que los resultado del Web form tambien me los lleve a me.php , que es el que quiero usar como Administrador de Form .

El archivo me.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
<?php
include 'ClassProveContakt3.php';
 
date_default_timezone_set('Europe/Paris');
error_reporting(-1);
error_reporting(E_ALL);
 
$ProveContackt=new ClassProveContakt3;
 
?>
 
<!DOCTYPE html>
<html lang="en_mx">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
 
<form name="form" id="form" method="POST" action="index4.php" >
 
<?php
 
     $ProveContackt->GetPostData();
 
     $ProveContackt->mella();
 
?>
 
</form>
</body>
 
</html>

el problema es que en este archivo solo la tabla enseña el horario , pero no ni el Nombre, Email y el Message , como el screenshot enseña...
8rldbqJ
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder