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.
Related
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.
This question already has answers here:
Passing an array using an HTML form hidden element
(8 answers)
Closed 3 years ago.
I have a form that submits various fields to create a new child job to the parent, but certain information from the parent job needs to be passed to the new job. There are a lot of fields that need to be passed to the new job, so I am wondering if it's possible to pass an array as a hidden field to a form.
I have searched online and found different options, such as passing the array as a concatenation, but I have too many fields to pass over. $job is the array I want to pass.
<form method="post" action="##">
<input type="hidden" name="job" value="<?php echo $job; ?>">
</form>
The error I got with the code above is "array to string conversion", which makes sense, but how do I get around it? There are many fields (probably close to 60) which need to be passed, so doing them one by one is not practical.
Any advice would be much appreciated.
You can pass the id of the parent job in the hidden field, on form submit action you can get the parent id and retrieve the information of that job.
<input type="hidden" name="parent_job_id" value="<?php echo $jobId; ?>">
Make sure which index holding the id of the parent job.
It seems $job is an array, you can not echo it, you can echo its index.
This question already has answers here:
How can I clear form values after successful form submission
(4 answers)
Closed 4 years ago.
I built a simple user registration form using Xtml, php Myadmin.i expect all the field to blank prior to inputing data.But each time i refresh the user registration page some field on the form will be pre filled. . What should i do so that form field should be blank prior to inputing data?
You can use the autocomplete tag like this
<input type="text" name="bar" autocomplete="off" />
To turn this browser behaviour off. Be aware that this does not work completely at some Firefox versions.
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
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