Getting value from form in php
I have a question about php: how do I get the value values from input from form, if form has not been sent yet, how do I do this? Or tell me how to do it so that when you click on input in php, only the value of input is sent? And also, if possible, how do I get the data in the same file without sending it to another one?
1
Author: Dmitriy Malishev, 2020-05-21
1 answers
In this code, the $message variable is created and the input value is entered into it. If you want to save the value of a variable after opening the page again, you can create a session (use a cookie).
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<form action="" method="post">
<input type="text" name="message" />
<input type="submit" name="send" value="Отправить" />
</form>
<?php
if(isset($_POST["message"])){$message = $_POST["message"]; echo $message;}
?>
</body>
</html>
0
Author: Anastasia, 2020-05-22 09:21:52