Is it possible to grab all the variables of a form at once to send to an email or do I need to declare one at a time?

Asked

Viewed 51 times

2

It is possible to grab all the variables of a form at once to send to an email or I need to declare one at a time?

<form action="welcome_get.php" method="get">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name="email"><br>
<input type="submit">
</form>


    <?php echo $_GET["name"]; ?>
    <?php echo $_GET["email"]; ?>

I had to write each one’s name

It is possible to do for example through a while or something like that not to have to write one by one?

  • How would you do it ? echo $_GET; ?

  • appears in this way :"{ ["datai"]=> string(0) "" ["weeks"]=> string(0) "" ["fullname"]=> string(0) "" ["Cpf"]=> string(0) "" ["databirth"]=> string(0) "" ["mail"]=> string(0) "" ["telf"]=> string(0) "" ["Cell"]=> string(0) "" ["nasc"]=> string(0) "" ["pass"]=> string(0) "" ["ppass"]=> string(0) "" ["datav"]=> string(0) "" ["gender"]=> string(5) "Other" }"

  • But then he gives me extra :P

  • 1

    try using the function filter_input_array($_POST), an example; $input = filter_input_array($_POST); and to access $input["name"]

1 answer

3


You can use a foreach:

foreach ($_GET as $key => $value) {
    echo $key . ' - ' . $value . '<br>';
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.