Some of the hidden $_POST Vairables failing to display within internal iframe - php

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

Related

Submit form through GET and preserve already existing GET parameters

Let's say I have a form that I send via GET:
<form method="get" action="/search.php?foo=bar&test=1&something=else">
<input type="text" name="day" placeholder="day"/>
<input type="text" name="link" placeholder="link"/>
</form>
And after submitting my form and processing the data (which consists of only saving it to a file), the url is changed to:
search.php?day=test&link=google.com
What should I do so the url becomes:
/search.php?foo=bar&test=1&something=else&day=test&link=google.com
(preserving the old parameters that were included in action attribute.)
The form action will change every time and it's difficult to keep the old GET parameters in the form action.
However, you can go with hidden fields.
Try this:
<form method="get" action="/search.php">
<input type="hidden" name="foo" value="bar"/> <!-- Add this -->
<input type="hidden" name="test" value="1"/> <!-- Add this -->
<input type="text" name="day" placeholder="day"/>
<input type="text" name="link" placeholder="link"/>
</form>
You could try changing the action before submitting, depending how you're going to submit the form. This can be done if you apply IDs to your texts and either a name or an ID to the form.
HTML:
<form id="frm" method="get" action="/search.php?foo=bar&test=1&something=else">
<input type="text" name="day" id="day" placeholder="day"/>
<input type="text" name="link" id="link" placeholder="link"/>
</form>
Then with JavaScript you can run a function and change the form's action:
var _form = document.getElementById('frm');
var day = document.getElementById('day').value;
var link = document.getElementById('link').value;
_form.action += '&day=' + day + '&link=' + link;
_form.submit();
You could try to use a hidden input field.
<input type="hidden" name="name" value="value">
if you are getting your variables first from get and then want to add into 2nd form you could get this and create input fields hidden with these get values
Now when you submit form in get url you will get all you desire data
<?php
if($_GET){
if(isset($_GET['submit1'])){
$foo = $_GET['foo'];
$test = $_GET['test'];
$something = $_GET['something'];
?>
<form method="get" action="/search.php">
<input type="hidden" name="foo" placeholder="foo" value="<?php echo $foo; ?>"/>
<input type="hidden" name="test" placeholder="test" value="<?php echo $test; ?>"/>
<input type="hidden" name="something" placeholder="something" value="<?php echo $something; ?>"/>
<input type="text" name="day" placeholder="day"/>
<input type="text" name="link" placeholder="link"/>
</form>
<?php
}
}
?>

PHP echo works on Page A but not on Page B

My goal is to populate a hidden form field with the utm_source from url.
Basically this:
<input id="fieldihhdji" name="cm-f-ihhdji" type="hidden" value="<?php echo $_GET["utm_source"] ?>" />
The problem is this form works perfectly on one page, but not on another.
Working: museumhack.com/test-a/?utm_source=hello (form field is hidden, but populates value)
Not working: museumhack.com/test-b/?utm_source=hello (at the bottom)
It seems like the pages may be processing the double quotes differently, but not clear how to fix. Wordpress required a plugin to process on page PHP -- I installed that and don't think it's the problem.
Here is the entire form that I copy/pasted between pages:
<form action="http://museumhack.createsend.com/t/d/s/ihhykl/" method="post" id="lead-capture">
<p>
<input id="fieldName" name="cm-name" type="text" placeholder="Your Name"/>
</p>
<p>
<input id="fieldEmail" name="cm-ihhykl-ihhykl" type="email" placeholder="you#email.com" required />
</p>
<p>
<input id="fieldjuuilj" name="cm-f-juuilj" type="text" placeholder="(212)555-5555" />
</p>
<p>
<input id="fieldihhdji" name="cm-f-ihhdji" type="hidden" value="<?php echo $_GET["utm_source"] ?>" />
</p>
<p>
<button type="submit">Request Quick Quote</button>
</p>
Thanks,
Try this code , this might help you
<input id="fieldihhdji" name="cm-f-ihhdji" type="hidden" value="<?php echo $_GET['utm_source']='';?>">

Double action form send user input to both email and new page

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

Show image based on selection on other page

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

how to pass values from one page to another on jquery form submit

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.

Categories