Why won’t my code work? (HTML) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why won’t my code work? (HTML)

I have a set of HTML code for a Messaging app. I wanted to export the message data as an array, but on the webpage (input page) it shows the code instead of running it, can anybody tell me what is wrong with it? <?DOCTYPE html> <form action="first.php" method="post"> <p>Name: <input type="text" name="Name" /></p> <p>Message: <input type="text" name="Message" /></p> <p>Time: <input type="text" name="Time: " /></p> <p><input type="submit" name="submit" value="Submit" /></p> </form> <?php $array = [ "Name" => .$_GET['Name'], "Message" => .$_GET['Message'], "Time" => .$_GET['Time'] ]; ?> file_put_contents('Chat.txt', print_r($array, true));

2nd Sep 2020, 6:07 PM
Dallas Griffith
Dallas Griffith - avatar
4 Answers
0
i am pretty sure mg PHP is outside the HTML, the last HTML tag is </form> and then it shows the php tag
2nd Sep 2020, 6:11 PM
Dallas Griffith
Dallas Griffith - avatar
0
You are using post method but in the code but you have $_GET. Use $_POST instead
2nd Sep 2020, 6:13 PM
Hima
Hima - avatar
0
i though the $_GET got the value of input text...
2nd Sep 2020, 6:15 PM
Dallas Griffith
Dallas Griffith - avatar
0
also, i tried that, it still shows the code as text ln the website...
2nd Sep 2020, 6:17 PM
Dallas Griffith
Dallas Griffith - avatar