The site is PHP feedback form, where there is a line:

if ($result){ echo "Сообщение отправлено"; 

after sending this notification is displayed at the end of the site in the "basement", where the PHP code itself is written, but it is necessary that this line be displayed under the feedback form itself. How can this be implemented?

  • Is it possible to move the check in the feedback form? - cheops
  • There is no such possibility - vladislav_zp
  • If it is not difficult to print out the code that forms the form, what can you catch there? - cheops
  • <form method = "POST" id = "feedback-form"> <p> Name: </ p> <input type = "text" name = "name" required placeholder = "Enter your name" x-autocompletetype = "name "title =" Enter your name "> <p> Email: </ p> <input type =" email "name =" email "required placeholder =" Enter your email "x-autocompletetype =" email "title =" Enter your email "> <p> Message: </ p> <textarea name =" message "required rows =" 5 "id =" message "title =" Enter your message "> </ textarea> <input type =" submit "type = "button" value = "SEND"> </ form> - vladislav_zp

1 answer 1

The simplest and most obvious answer is to insert the code to send the letter to the top of the page, where it belongs to (usually all of the logic goes to the top of the page so that all the necessary data will be obtained by the time it is displayed on the page). In the same place to form the message, approximately so

 $message = ''; if ($result) $message = "Сообщение отправлено"; 

And then output it in the right place.

 echo $message; 

There is also a crutch option to display a message in a hidden block and use javascript to move it to its destination and make it visible.

  • The fact is that $message = ' '; is already used in the code itself in the following way: $message = 'Name: '.$_POST['name'].'; Email: '.$_POST['email'].'; Message: '.$_POST['message'].';'; $message = 'Name: '.$_POST['name'].'; Email: '.$_POST['email'].'; Message: '.$_POST['message'].';'; - vladislav_zp
  • @vladislav_zp well, call another variable, what's the problem) - Ivan Pshenitsyn
  • now nothing is displayed on the screen at all .. - vladislav_zp
  • "now" - when is this?) maybe share what you tried to do? - Ivan Pshenitsyn
  • changed the name of the variable: $ displaymessage = ''; if ($ result) $ displaymessage = "Message sent"; ///////////////////// and under the send button I inserted <? php echo $ displaymessage; ?> - vladislav_zp