How to get the post data without form builder [duplicate] - php

This question already has answers here:
Access POST values in Symfony2 request object
(9 answers)
Closed 8 years ago.
Normally I am using formbuilder to get the post data from form.
However,now I need very simple form not relevant with entity.
I can get the method like this and
if ($this->getRequest()->isMethod('POST')) {/
I want to get the each form data.(name is form name)
echo($this->getRequest()->get('name')->getData());
it shows error.
I used to use formbuilder and bindRequet normally to pick the data from form object.
How can I get the each form data from this->getRequest() without using formbuilder?

You could get it from the request property:
$this->getRequest()->request->get('foo');

Related

Adding Values to Array and keep existing values [duplicate]

This question already has answers here:
Keep values selected after form submission
(12 answers)
Closed 3 years ago.
I am trying to find what the easiest way to keep form values after post. I am really trying to have to keep from learning ajax right this second for the one form, Plus I am not sure how hard it would be to implement ajax into my already existing google map page. So I am trying to find a way to retain the values of two date fields after submit has been pushed
If you are looking to just repopulate the fields with the values that were posted in them, then just echo the post value back into the field, like so:
<input type="text" name="myField1" value="<?php echo isset($_POST['myField1']) ? $_POST['myField1'] : '' ?>" />
you can save them into a $_SESSION variable and then when the user calls that page again populate all the inputs with their respective session variables.

Anyone know how I would send form data without page refresh? [duplicate]

This question already has answers here:
How to send form data without page refresh?
(6 answers)
Closed 4 years ago.
I have a form sending chat messages to database and a php file getting them on a page as styled elements I use ajax to get messages from my php file and display them every 2 seconds.
The only problem is that when the form is submitted, it refreshes the page.
Which is quite annoying.
Anyone know how I could get data to the database without the page refreshing?
Submit your form with a button that is not an input of type submit and call a javascript function in the onclick event that makes an ajax call. That will prevent the page from refreshing.

How to get the data from input without attribute name? [duplicate]

This question already has answers here:
Does form data still transfer if the input tag has no name?
(3 answers)
Closed 9 years ago.
I read $_POST is empty after form submission topic and I wondered how to get the data from input without attribute name?
<input type="text" >
var_dump($_REQUEST)//empty
var_dump(file_get_contents('php://input')) //empty
Basically, the form should be specified its name. If not, you cannot get it from the server-side.
However, the form without name is also valid in HTML5. The reason is that you might sometimes want to use for form submission via AJAX or Javascript app. In many cases

how to submit a form from a php script [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Auto Submitting a form (cURL)
I have a form which submits to a php script. In this form I need to collect all the $_POST data and then post this on to another form (the reason for this isn't really relevant but there is a good reason).
My question is once I've collected all the data from the initial form submit, sanitised it and assigned it all to variables how do i then package it all up to send to the next form? The second form is expecting a $_POST with hidden fields with particular name attributes....so how do i do this? do I build the actual html and submit that somehow to the second form or do I buld some sort of array and send that?
hope this makes sense. Kind of hard to put in to words.
You can generate form and submit onLoad by Javascript
You can use curl to send POST query (from your server but not from client)
The better way woudl be to store the sanitized variables in the session.
Collect all the information you need from all the forms you need.
Then after you have all the data needed, then finally update the DB (or Somethign else)
if I understood you well when you open the form you tell it wich acction will it perform
.when you click submit it will take you to the other form.in the other form you can access the values of the input fields from the previous form with $_POST['name_of_the_input_field'].i hope this will help you :D

How to keep form values after post [duplicate]

This question already has answers here:
Keep values selected after form submission
(12 answers)
Closed 3 years ago.
I am trying to find what the easiest way to keep form values after post. I am really trying to have to keep from learning ajax right this second for the one form, Plus I am not sure how hard it would be to implement ajax into my already existing google map page. So I am trying to find a way to retain the values of two date fields after submit has been pushed
If you are looking to just repopulate the fields with the values that were posted in them, then just echo the post value back into the field, like so:
<input type="text" name="myField1" value="<?php echo isset($_POST['myField1']) ? $_POST['myField1'] : '' ?>" />
you can save them into a $_SESSION variable and then when the user calls that page again populate all the inputs with their respective session variables.

Categories