Domanda

So i have a couple of forms where I want the value to be echoed out. Ex." Hi Mr. (form1 value) how are you?. " This preferably on the same page, like under the forms.

My code so far. Im really new to this.

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Din sång</title>
    <h1>Skriv din egna sång!</h1>
    <body>
        <form method="post">
            Ange namn<input type="text" name="Namn">
            <br>
            Ange egenskap <input type="text" name="egenskap">
            <br>
            Ange en till egenskap  <input type="text" name="egenskap2">
            <br>
            Något du gör(verb) <input type="text" name="Verb">
            <br>
            <input type="submit" value="Komponera">
        </form>

        <?php
        ?>

    </body>
</head>
È stato utile?

Soluzione

in the php tag :

<?php
    if (isset($_POST['Namn'])){
        exho 'Hi Mr. '.htmlspecialchars($_POST['Namn']).' how are you?';
    }
?>

Altri suggerimenti

Try this:

<?php
echo "Hi mister " . $_POST['name'] . "<br>";
echo "<p>Ange en till egenskap: " . $_POST['egenskap'] . "</p>";
?>
<?php if(isset($_POST['Komponera'])) 
{
    echo "Hi Mr.'".$_POST['Namn']."' how are you?.";
}
?>

Try this.

in the $ _POST array contains all value passed in form POST method, similar to the works and the array $ _GET

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top