Blank Blank -5 years ago 100
HTML Question

Get the value of input and show in letter

Im trying to get the value of an input and display it in a letter.
The letter is visible a section which is visible after the user fills in the input with his/her name to make the letter more personally.

<section id="formulier">
<h3>Welkom op mijn pagina, vul de gegevens in om mijn motivatiebrief te kunnen zien.</h3>
<form class="formulier-gegevens" name="form" action="" method="post">
<input type="text" name="voornaam" class="formulier-input" placeholder="Vul uw voornaam in" required>
<input type="text" name="tussenvoegsels" class="formulier-input" placeholder="Vul uw tussenvoegsel(s) in">
<input type="text" name="achternaam" class="formulier-input" placeholder="Vul uw achternaam in" required>
<button class="verzend btn btn-lg btn-primary btn-block" type="submit">Verstuur</button>

<section id="brief">
<h3>Hier komt de motivatiebrief </h3>
$voornaam = $_POST['voornaam'];
$tussenvoegsels = $_POST['tussenvoegsels'];
$achternaam = $_POST['achternaam'];

echo $voornaam;

This is what I have till now, but when the user submits, the
is not shown. How can I accomplish this the easy way?

P.s. I want to use PHP and not JavaScript.

Answer Source

Your code seems fine. First check if you are saving the file with a php extension. Then start the php file with

    //save the variables from POST
      Put your html here and when you need to call the variables from php just write the following 

<?php echo htmlentities($voornaam, ENT_QUOTES, 'utf-8'); ?>


You should always start a php file with php tags.

If this does not solve the problem check if php is active and installed properly with

<?php phpinfo(); ?>

at the start of a php file.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download