I have build a system to put together a shed, this is done with several pages with radio buttons and forms.
The problem is that with this form i use action and POST to send the result to the next page.
But i want the input for example on page 1 to be send to page 2 and 3, currently thats impossible because you can only have one action in your form.
<form action="lounge-kamer3.php" method="POST">
I need the input from page 1 for an if statement on page 2 and 3. how do i do that?
Couldnt find an easy way on the internet, and because i do not master english that well it sometimes is hard to understand.
Hope i am clear enough.
ps. sorry for my english, not my first language.
Perhaps try using a hidden field, a cookie, or session info to carry information across pages.
How to pass information across web pages of a web site
You might want to write the requests asynchronously and then you can continually reuse info on the page with js and php.
You should use hidden fields.
In page 1, let's say 2 have 2 fields, in page 2, you have other 2 fields, but you actually have 4: 2 visible, and 2 hidden. These hidden fields must have the value: the $_POST['field1']
Example:
Page1.php:
<form action="page2.php" method="POST">
<input type="text" name="one">
<input type="submit">
</form>
page2.php:
<form action="page3.php" method="POST">
<input type="hidden" name="one" value="<?php echo $_POST['one']; ?>">
<input type="text" name="two">
<input type="text" name="three">
<input type="submit">
page3.php:
<form action="end.php" method="POST">
<input type="hidden" name="one" value="<?php echo $_POST['one']; ?>">
<input type="hidden" name="two" value="<?php echo $_POST['two']; ?>">
<input type="hidden" name="three" value="<?php echo $_POST['three']; ?>">
<input type="text" name="four">
<input type="submit">
</form>
end.php
<?php
echo $_POST['one'];
echo $_POST['two'];
echo $_POST['three'];
echo $_POST['four'];
?>
http://www.echoecho.com/htmlforms07.htm
http://www.tizag.com/htmlT/htmlhidden.php
hidden field in php
Related
I am new to coding and have learned a whole lot in the last 12 months using S/O so i would like to say thanks for helping me out and any input is more than appreciated.
I have created a 4 page Registration form that consists of the following process:
1. index.php (Main page / Landing page with form input values)
2. page2.php (Select date, time and confirm appointment)
3. page3.php (Booking confirmed please Select nearest location, Survey and service)
4. SSL Payments page with iframe insert from 3rd party
on page3.php i have inserted an internal iframe that is hosted on the same server, using separate css files, js, ect.. So due to my lack of coding skills i found it easier to insert the iframe rather than merging the page as 1 complete page.
Now on all pages i have managed to get the $_POST Variables passing from page 1 --> 2 --> 3
But on page 3 i fail to get all the variables displayed in the iframe hidden inputs. I can not understand why only some are being displayed and others are not.. When the form gets submitted the only ones that come through are the ones you can see hidden in source code.
i have also tried to do the following:
insert <?php session_start();?> at the top of the page
and at the bottom of page i have:
<?php
$_SESSION['Name']=$_POST['Name'];
$_SESSION['Postcode']=$_POST['Postcode'];
$_SESSION['Building']=$_POST['Building'];
$_SESSION['EmailAddress']=$_POST['EmailAddress'];
$_SESSION['Telephone']=$_POST['Telephone'];
$_SESSION['datepicker']=$_POST['datepicker'];
$_SESSION['timeofsurvey']=$_POST['timeofsurver'];
$_SESSION['PropertyOwner']=$_POST['PropertyOwner'];
?>
I have these on each page to make sure they get passed across each page, All the input ['names'] are correct and on the same page where the iframe is they are displayed back to the user in a text box to the right side of the iframe basically to show the user that their information is correct while booking their appointment.
Here is my iframe form source code:
<div id="app" my-app my-controller="Controller">
<form action="Processing.php" id="regForm" name="regForm" method="post">
<input type="hidden" value="<?php echo $_SESSION['Name'];?>" name="Full Name">
<input type="hidden" value="<?php echo $_SESSION['Telephone'];?>" name="Telephone">
<input type="hidden" value="<?php echo $_SESSION['EmailAddress'];?>" name="Email">
<input type="hidden" value="<?php echo $_SESSION['Building'];?> " name="Building Number or Name">
<input type="hidden" value="<?php echo $_SESSION['Postcode'];?>" name="Postcode">
<input type="hidden" value="<?php echo $_SESSION['PropertyOwner'];?>" name="PropertyOwner">
<input type="hidden" value="<?php echo $_POST['datepicker'];?>" name="Survey Date">
<input type="hidden" value="<?php echo $_POST['timeofsurvey'];?>" name="Survey Time">
The only hidden variables failing to display are the following:
['Name']
['EmailAddress']
['datepicker']
['timeofsurvey']
All other variables are being displayed fine, As i said even the page that has the iframe inserted is also displaying all variables back to the user correctly. If you click to view page source code you see them fine... Then as soon as you view the inner iframe source code you see the variables above are missing.
This is the outcome when viewing the iframe source code:
<div id="app" my-app my-controller="Controller">
<form action="Processing.php" id="regForm" name="regForm" method="post">
<input type="hidden" value="" name="Full Name"> **<----- This input is missing**
<input type="hidden" value="0123456789" name="Telephone">
<input type="hidden" value="" name="Email"> **<------- This input is missing**
<input type="hidden" value=" " name="Building Number or Name">
<input type="hidden" value="NW1 1AA" name="Postcode">
<input type="hidden" value="Yes" name="PropertyOwner">
<input type="hidden" value="" name="Survey Date"> **<--- This input is missing**
<input type="hidden" value="" name="Survey Time"> **<--- This input is missing**
<input type="hidden" name="field_passthrough1" value="Consumer" />
<input type="hidden" name="field_passthrough2" value="en-UK" />
I hope i have not gone the longest way round here trying to explain, as i understand a lot of you guys are really to busy to be reading long posts like mine when it will be something so simple.. I have spent 2 days trying all sorts to get this working and i can not seem to get a way round this.
I would really appreciate any help guys, Thank You.
############# UPDATE TO LAMONDE ################
This is how i now have the iframe and the only fields that are now missing is:
['Name']
['EmailAddress']
['Building']
---> ['datepicker'] and ['timeofsurvey'] are now working...
<input type="hidden" value="<?php echo $_SESSION['Name'];?>" name="Name">
<input type="hidden" value="<?php echo $_SESSION['Telephone'];?>" name="Telephone">
<input type="hidden" value="<?php echo $_SESSION['EmailAddress'];?>" name="EmailAddress">
<input type="hidden" value="<?php echo $_SESSION['Building'];?> " name="Building">
<input type="hidden" value="<?php echo $_SESSION['Postcode'];?>" name="Postcode">
<input type="hidden" value="<?php echo $_SESSION['PropertyOwner'];?>" name="PropertyOwner">
<input type="hidden" value="<?php echo $_SESSION['datepicker'];?>" name="datepicker">
<input type="hidden" value="<?php echo $_SESSION['timeofsurvey'];?>" name="timeofsurvey">
Here is source view on page3.php iframe:
<input type="hidden" value="" name="Name">
<input type="hidden" value="07541258585" name="Telephone">
<input type="hidden" value="" name="EmailAddress">
<input type="hidden" value=" " name="Building">
<input type="hidden" value="saas" name="Postcode">
<input type="hidden" value="No" name="PropertyOwner">
<input type="hidden" value="21/01/2015" name="datepicker">
<input type="hidden" value="4:30 pm" name="timeofsurvey">
Your $_POST will have the same name has your input.
So: $_POST['Name'] != $_POST['Full Name'];
It's pretty much the same for every input that are missing.
Also you really shouldn't use spaces in input names
I wish to use a single HTML form to send the user's input to my email, and simultaneously a web page that the user views their input. At present I can only get one of the two options; the web page re-direct which displays the users input.
Is there a back-side PHP script to accomplish sending the user input to both an email and a web page?
Form code:
<form id="form1" name="form1" method="post" action="TEST.php">
<input name="name" type="text" class="formdetail" id="name" />
<input name="color" type="text" class="formdetail" id="color" size="45"/>
<input name="animal" type="text" class="formdetail" id="animal" size="45"/>
<input name="room" type="text" class="formdetail" id="room" size="45"/>
<input name="water" type="text" class="formdetail" id="water" size="45"/>
<input name="email2" type="text" class="formdetail" id="email" size="45"/>
<input type="submit" name="submit2" id="submit" value="Submit" />
<input type="hidden" name="recipients" value="http://www.Website.net/TEST.php" />
<input type="hidden" name="good_url" value="http://www.Website.net/TEST.php" />
</form>
Results web page page code:
<p>Your results, <?php echo htmlspecialchars($_POST['name']); ?>:</p>
<p>1. Your favorite color reveals: <?php echo htmlspecialchars($_POST['color']); ?>.</p>
<p>2. Your favorite animal reveals: <?php echo htmlspecialchars($_POST['animal']); ?>.</p>
<p>3. This reveals: <?php echo htmlspecialchars($_POST['room']); ?>.</p>
<p>4. This reveals: <?php echo htmlspecialchars($_POST['water']); ?>.</p>
So if I'm understanding your question correctly you want that script to send the user on to the next page after it emails you?
It's really very simple :)
First, you need to store your data into some persistent store, such as a session using start_session() on your first page. This will allow you to store data in the $_SESSION super global. Then on your next page after using:
http_redirect($newUrl);
You can grab the session data using that same superglobal
Place that after your email code and you should be good to go. If you're asking something a little different please don't hesitate to call me out and we can figure this thing out.
For reference: http_redirect() in a nutshell
And: php sessions in a nutshell
So I am having an issue. I used POST to send data to a new page. I use get to send data to a function but it seems the POST data get wiped. Here some code to help explain.
POST CODE to send to form vieworder (works perfect!)
<form method="post" action="vieworder.php">
<input type="hidden" name ="user_id" value="<?php echo $_SESSION['user_id']; ?>">
<input type="hidden" name ="id" value="<?php echo $data1[$x]['id']; ?>">
<input type="submit" name="submit" value="View"> </td>
</form>
So on the vieworder page I want used to be able to update the data using this form.
This form works as well except i need that value "id" from the orginal post. It works and the "id"has the data until I use this form.
<form name="approveform" method="get" action="">
Index Number*: <input type="text" name="IndexNum">
<input type="submit" value="Approve" action="">
</form>
I would also prefer to use the POST method but using GET was my first solution to no deleting the data from POST.
Anyways I then just send the data to a function to update two fields.
Any way to get correct the code?
<?php
$id=$_POST['user_id'];
?>
<form name="approveform" method="get" action="">
Index Number*: <input type="text" name="IndexNum">
<input type='hidden' value='<?php echo $id;?>'>
<input type="submit" value="Approve" action="">
</form>
I have a form with a submit button and a handler that stores data in the database. Problem is when the form is submitted, all data is cleared from the input fields. Is there a way to still show them after submit? What changes do I need to make to my form_submit function?
function mymodule_form_submit($form, &$form_state) {
//how to retain the input in the form
}
I'm looking for the most "drupalish" way to get this done?
As indicated by this previous StackOverflow question you can accomplish this with $form_state['storage'] and $form_state['rebuild'].
You can access the data using $_REQUEST['form_variable_name'] where form_variable_name is the name of the html input tag.
You then need to render the page back putting this value into the input tags value field.
<form method="POST" action="/account/contactdetails/">
<div>
<label>First name:</label>
<input type="text" name="firstname" value="<?php echo $_REQUEST['firstname']; ?>" />
</div>
<div>
<label>Last name:</label>
<input type="text" name="lastname" value="<?php echo $_REQUEST['lastname']; ?>" />
</div>
<input type="submit" value="Save" />
</form>
I'm trying to build a form using php & jquery, but I'm a little confused as to what to do with the jquery portion of it...
Basically, when the user submits the first form, I want to direct them to the "next step" form, but I want to retain the values submitted from the first one in a hidden input field...
If someone can either show me how or point me to a good tutorial, I'd appreciate it...
I don't have any of the php or jquery yet, and this is just a simplified version of the html markup...
//first.php
<form name="form1" method="post" action="second.php">
<input type="text" name="name" value="" />Name
<input type="submit" name="step1" value="Next" />
</form>
//second.php
<form name="form2" method="post" action="process.php">
<input type="hidden" name="name" value="{$_POST['name']}" />
<input type="text" name="message" value="" />message
<input type="submit" name="step2" value="Finish" />
</form>
<input type="hidden" name="name" value="{$_POST['name']}" />
should be,
<input type="hidden" name="name" value="<?php echo $_POST['name']}; ?>" />
and also sanitize the input, if you want
I don't no if there is a better way to do that.
But, when I need to do such thing, I do in this way:
<script>
<?php
foreach($_POST as $key => $valule)
{
echo "$('$key').val('$value')";
}
?>
</script>
So, in your nextstep file, all you'll need to do is set up the hidden fields and then just loop through the post vars and set each one via jquery.