<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <center> <h1>Alladin</h1> <?php echo " <h3> В одном персидском городе **$city** жил бедный портной [tailorName]. У него были жена и сын по имени [sonName]. Когда Аладдину исполнилось [age] лет, отец его сказал: — Пусть мой [sonName] будет портным, как я,— и начал учить Аладдина своему ремеслу. </h3> "; ?> </center> </body> </html> 
  • 2
    #offtop: "The right question is half the answer." As I understand it, you have a form on index.html, where action = "index.php" is registered, and you need to substitute the form to get the content that you showed us (<center> </ center>) and output it somewhere .. then use ajax request. - Sultanov
  • Here you need to display in the text: echo "In one Persian city [display the contents] lived a poor tailor [display the contents]. He had a wife and son named [display the contents] [display the contents]. When Aladdin turned out [to display the contents] years, his father said: “Let my [display the contents] be a tailor, like me, - and began to teach Aladdin his craft."; and the option echo $ _POST ['city'] does not fit - Alexander Zharichenko

2 answers 2

You must have a form in index.html

 <form action="index.php" method="post"> <input name="tailorName"> <input name="sonName"> <input name="age"> <input name="city"> </form> 

Further in index.php

 <?php echo "<h3> В одном персидском городе ". $_POST["city"]. " жил бедный портной " . $_POST["tailorName"] . ". У него были жена и сын по имени " . $_POST["sonName"] . ". Когда Аладдину исполнилось " . $_POST["age"] ." лет, отец его сказал: — Пусть мой ". $_POST["sonName"] ." будет портным, как я,— и начал учить Аладдина своему ремеслу. </h3> "; ?> 
  • Thank you, it works. There was a shortage of $ _POST ["city"] - Alexander Zharichenko

For the form we write action = "./ index.php", for each field in the form, write the name = "" In the php file, all data will be displayed in $ _POST, make print_r ($ _ POST) for clarity

  • I try this, but it returns an error: <? Php echo "<h3> In one Persian city." echo $ _POST ['city']. "poor tailor lived [tailorName]. He had a wife and son named [sonName]. When Aladdin turned [age] years old, his father said: - Let my [sonName] be a tailor, like me, - and began to teach Aladdin to craft. </ h3> "; ?> - Alexander Zharichenko