There is a Codeigniter scenario wherein the First form contains textarea, checkboxes.
After filling in user goes to 2nd page. There is button Previous to go back to 1st page.
The problem is 1st form's is populated with values set before.
I would like to have a page without auto populating.
Any help would be great. Thanks.
Your navigator keep in cache your data, look to :
<input type="text" name="foo" autocomplete="off" />
Related
How to bring the first input box value to second input box after clicks the confirm button and refreshing the page.
But I dont want to save the value in the database, I just want to bring the value from first input box to the second input box after clicks the confirm button and refreshing the page. The first input box value will show into the second input box.
After that, How should I pass the second input box value to another page?
You have also a js API for cookies, cache and local/session storage, as well as IndexedDB, so you can use JS.
But why you need to refresh the page?? You could just put this value in a second field with JS without refreshing the page.
If you need badly to refresh the page after form validation, you have all form data sent by POST or GET, use the corresponding variables $_POST or $_GET in PHP and then echo wherever you want.
Or another option, if you need this value to be accessible all over your site/project and you use Sessions, you could save this value in the $_SESSION variable.
There are a lot of possible solutions, everything depends on your needs and goals.
Put this into top of the file
$first_value = isset($_POST['first_input']) ? $_POST['first_input'] : "";
and this into the form
<form action="_white.php" method="POST">
<input type="text" name="first_input">
<button>Confirm</button>
<input type="text" name="second_input" value="<?php echo $first_value; ?>">
</form>
It works
I have a html form where I take all the user data and then insert/edit in the database. Then I also have a search button which shows all the available entries in the database. Problem is, when I click on a particular entry,I want all it's data in the form..in an editable format..how can I do it??
I tried storing all data in session variables and then redirecting it to the main page containing the form then assigning session variables to respective form field,but it's not working (as it says undefined when you first load the page).
https://i.stack.imgur.com/usyUf.png this image shows the error when I first load the form...all help appreciated!
PS- I did use session_start() at the beginning!
All you have to do is put the database values in "value" attribute of input form.
e.g.
<input type="text" name="User" value="<?php echo $User;?">
Here, $User is a variable which stores the User Name retrieved from Database.
I have a form that i want to filled up by the end user in few steps.
in the first step i want to let them fill Name,Address,Mobile number.
And when click next button i want to appear another part of the form to fill the other details such as upload a image .
i did research online,i found 2 articles useful,
One thing is about sessions and the other thing is about hidden fields.
In my opinion i think sessions are not a good way to use for form submitting.Because some browsers are might have disabled sessions.
So ill go with hidden fields.
In my database i have a unique id which is auto increment.What i want to do is to let user to submit a form.In the first step i want them to submit their name,addres,mobile number(In this time it is inserting data to the database- Only for couple of columns.) And in my database i have a field for upload a image.In the first step it gets a null value.I want to update that null value in the next step by getting a that id from the first step
Please give me the basic idea to start this.A little help much appreciated!
Thanks in advance
you can try like this:-
You can add a class on the input which you want to hide
<input type="text" name="example" class="inputHidden">
after that add style in your page like this
<style>
.inputHidden{
display:none;
}
</style>
If you're trying to place the form data into new, hidden inputs - take the initial input.
<input type="text" name="example">
On the next page add a hidden input.
<input type="hidden" name="exampleP2" value="<?php echo $_POST['example']; ?>">
You can get form submited data and use it in input hidden fileds
for e.g. in first form you have
name ,email etc fields
in other form you have more fields
here you can use <input type="hidden" name ="firstname">
and thus you can add as many as you want
I am handling a survey multistep form with many radio sets.
They have some default states
User operates over them to select his preferences.
Now the client wants when hitting either browser back button or the side navigator links (a set of links pointing to previous stages of the survey) to have the radio states the user previously chose.
Here is how the navigator looks like:
<ul>
<li>Step1</li>
<li>Step2</li>
<li>Step3</li>
</ul>
There is only one $_SESSION that collects data throughout the survey.
I know I can load information directly from $_SESSION but I need to replace the default states when the request comes from the navigator links/ back button.
After posting form, you can save values in the session. When accessing previous page again (or even first load it), read session's values and check specified radios. If you access page first time, there will be no data in the session, so no one will be checked.
You can also store selected values lively with JavaScript and cookies.
There are two main approaches to this, basically you are saying that the chosen state of the radio's need to be saved between different pages of your form.
So when you return to a page you were on previously but without submitting, the choices should still be the same.
There are two key approaches, server side with PHP or client side with Javascript
PHP
You can set any link on the website to submit the form and you could save the radio selections, then when you create the form you can check the previously selected value
This information could be saved in $_SESSION but they'd need to submit the form each time they changed the page (you could change the links to do this)
Javascript
You could write some javascript that remembered the content of the selections and stored them in the users browser as a cookie, this could update everytime they clicked a button. When the page loads the javascript would check for cookies (or local storage) and would load the previous options.
When they finish and submit the form you'd clear the javascript
Basic example
$('form input[type=radio]:checked')
Once I have more information I'll flesh out this answer further
A very simplified possible solution:
<?php
session_start(); // this needs to be at the top of all pages using $_SESSION (before anything else) else $_SESSION will always be empty
if($_POST['vehicle']){
$_SESSION['checkbox1'] = $_POST['vehicle'];
}
print_r($_SESSION); // remove this line after testing. It will show you the contents of the $_SESSION, which is handy for seeing when variables are set within it
?>
<!DOCTYPE html>
<html>
<body>
<form action="" method="post">
<input type="checkbox" name="vehicle" value="Bike"<?php if($_SESSION['checkbox1'] == "Bike"){ echo " checked"}?>>I have a bike<br />
<input type="checkbox" name="vehicle" value="Car"<?php if($_SESSION['checkbox1'] == "Car"){ echo " checked"}?>>I have a car <br />#
<input type="submit" value="Go" />
</form>
</body>
</html>
You could add a unique id generated at the first page in a hidden input area that when posted could form part of the session variable name. From there the information would be indexed in the $_SESSION under that variable name making it easier to pull the data back out or to create a new form session as it were.
Hope I haven't lost you.
I have a PHP web page. Initially, the values in the text box are retrieved from a LDAP directory based on the user login information. The user makes any required changes in the values and on clicking submit the values in the text box get updated and also the values in the Directory get updated as well( I have got this part done). I am new to PHP and I am trying to figure out how to update the values in the text box on submit.
With PHP you can only do changes on submit when you do a AJAX call to the server. However, you can do changes using only PHP after submitting it on the server side.
Updating in the browser directly "onsubmit" is not possible without the help of JavaScript.
You want to take the values the user has submitted and redisplay them in your text field.
Something like
<input type="text" name="phone_num" id="phone_num" value="<?php (isset($_POST['phone_num']) ? $_POST['phone_num'] : $valueFromLDAPDir) ?>" />