Submit a form using request in php

Asked

Viewed 179 times

1

Good morning guys,

I am making a form (course work) and need to echo in all information typed in the form using REQUEST (can be POST too) when I click the "Submit button".

I searched the internet a lot, I saw several videos, but I just think how to do this given, like, making a line of code for each data... but it’s a lot of data on the form and I remember that my teacher made a single line that printed all the information typed, but I don’t remember how he did it.

  • 1

    You can use var_dump($_POST) or var_export($_POST) or print_r($_POST)...

  • I needed to use echo and request pq was what he asked for, but if I don’t get it I’ll try what you said. Just put one of the 03 q vc listed between the php tag? need reference to the file? never used any of the 03.

  • 1

    echo var_export($_REQUEST, true); or use a foreach and iterates over all received fields

  • Thanks, I’ll test it as soon as I get home.

1 answer

0

In addition to the options suggested by Fernando...

If you need give echo in all information typed in the form I would do so:

echo implode(" ", array_slice($_REQUEST,0,count($_REQUEST) - 1));

The array_slice will take everything that was typed except the Submit. While the implode will join all values of array elements by placing a spacing between them.

  • 1

    Thank you very much!!

  • @Rwprogramer this works if Submit is at the end of the form

Browser other questions tagged

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