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']='';?>">
Related
this is a page that displays a list of creatives, and the form offers search functionality to search by job title:
if(isset($_POST['creatives-submit'])){
$job = $_POST['job-title'];
$data = \Db::Common($fms5->DBH)->getWhere("creatives", "creatives_active", "Yes"," AND creatives_job LIKE '%".$job."%'")->orderBy('creatives_name', 'asc');
}
<form method="post" name="creative-search">
<input class="form-control" type="textbox" name="job-title" id="job-title" placeholder="Search by job title" />
<input class="form-control" type="submit" name="creatives-submit" id="creatives-submit" style="display: none;" />
</form>
is there anything that's obviously wrong my my code?
try changing if(isset($_POST['creatives-submit'])) to if(isset($_POST['job-title']) && !empty($_POST["job-title"])) as the form is posting the job-title value and this is the value you actually care about. (Since creatives-submit will always = Submit)
also change
<input class="form-control" type="textbox" name="job-title" id="job-title" placeholder="Search by job title" />
to <input class="form-control" type="text" name="job-title" id="job-title" placeholder="Search by job title" required/>
this means the form can't be submitted unless the job-title field has a value and had the correct type of text
Below is a modification of your code that just returns what the user searched for (Since I don't have it connected to a database)
<?php
if(isset($_POST['job-title']) && !empty($_POST["job-title"])){
$job = $_POST['job-title'];
?>
<p>You Searched For <?php echo $job;?></p>
<?php
}
?>
And the form
<!-- Search Form -->
<form method="post" name="creative-search">
<input class="form-control" required="required" type="text" name="job-title" id="job-title" placeholder="Search by job title" />
<input class="form-control" type="submit" name="creatives-submit" id="creatives-submit" style="display: none;" />
</form>
I don't know what the heck the problem is with this form not working. The form is not to be sent anywhere. It's just a questionnaire for clients to fill/print out if they like, but I cannot get the results to post into the hidden div. What am I doing wrong? I installed a wordpress php plugin and other php echo's work, but not the POST thing. The HTML:
<form method="post">
<input type="text" placeholder="Your Name" name="yourname" />
<br /><br />
<input type="text" placeholder="Pet's Name" name="petsname" />
<br /><br />
<input type="text" placeholder="Pet's Birth Date" onfocus="(this.type='date')" onblur="(this.type='text')" id="date" name="petsbirthdate" />
<br /><br />
<strong>Pet's Sex</strong>: <input type="radio" value="Male" name="sex" id="Male" /><label for="Male">Male</label> <input type="radio" value="Female" name="sex" id="Female" /><label for="Female">Female</label>
<button type="button" class="button" onclick="show_output();">Display
Answers</button>
</form>
Pay no attention to the onclick handler on the button. I'm not including that JavaScript, but just know that the hidden div does show when the button is clicked. The PHP that returns no form results: Pay no attention to the PHP in brackets, that's the way it works in WordPress with the plugin.
<p class="data_answers">
<strong>Your Name:</strong> [php]echo htmlspecialchars($_POST['yourname']);[/php]</p>
<p class="data_answers">
<strong>Pet's Name:</strong> [php]echo $_POST['petsname'];[/php]</p>
<p class="data_answers">
<strong>Pet's Birth Date:</strong> [php]echo $_POST['petsbirthdate'];[/php]</p>
<p class="data_answers">
<strong>Pet's Sex:</strong> [php]echo $_POST['sex'];[/php]</p>
The PHP that will work (anywhere; I even placed it in the middle of, where the form answers should be, and it shows up. So why doesn't the other work?
[php] echo "Hello world!"; [/php]
Thank You!
Tracy
P.S. Although you cannot see the PHP, but the actual page in draft is here: http://www.safarivet.com/behavior-conditions/
You should add the action attribute in the form tag
<form method="post" action="">
..leads back to the same page
Extending from Johannes answer, you can also use a number sign # or the global variable $_SERVER['PHP_SELF']
Either of these will work
<form method="post" action"">
<form method="post" action"#">
<form method="post" action"<?php echo $_SERVER['PHP_SELF']?>">
I have been trying to pre-fill the subject input with information generated in another page, but have been having difficulties with it despite reading a lot of resources about it and seeing examples. I have tried a variety of links, including my most recent attempt with http://www.myurl.com/folder/index.php/contactform?subject=test, but even that doesn't work. Anybody have any advice? Also, if you want to test it out before answering, the page experiencing the problem is the contact page of this website. I've removed information from below to make it more general. Thanks in advance for any and all of the help.
<form id="contactform" method="post">
<input name="recipient" type="hidden" value="myemail" />
<input name="subject" type="hidden" value="Contacter" />
<p id="contactname">
<label>Name:</label>
<input name="name" type="text" />
</p>
<p id="contactemail">
<label>Email:</label>
<input name="email" type="text" />
</p>
<p id="title">
<label>Subject:</label>
<input name="title" type="text" />
</p>
<p id="contactmessage">
<label>Message:</label>
<textarea name="message"></textarea>
</p>
<p id="submit">
<input type="button" value="Send" />
</p>
<input name="redirect" type="hidden" value="myredirectpage" />
</form>
Lets say your page URL is some thing like below
http://www.example.net/index.php?var1=Something&var2=10&var3=ok
You can use $_GET to get the values of var1, var2,and var3 from the above url
In index.php use the below code to fetch url data
echo $_GET['var1'] // Something
echo $_GET['var2'] // 10
echo $_GET['var3'] // ok
Go through this link http://php.net/manual/en/reserved.variables.get.php
With php you can do this with a session.
On the other page(not the form) you can do $_SESSION['subject'] = 'your subject';
On the form page you can acces this cookie ( make sure you have started the session on top of the page with session_start():
<p id="title">
<label>Subject:</label>
<input name="title" type="text" value="<?= $_SESSION['subject'] ?>"/>
</p>
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 have been reading extensively about this and cannot seem to find a resolution. I have created a form in PHP which I want to submit to the same page I am on. I have read that there are some name's that wordpresses reserves such as "name" - which I am not using. Does anyone have any idea why this redirects to page not found upon submission?
http://hybridhosting.net/markeim/properties/52-coles-road/
<form action="" method="POST">
<input type="hidden" id="my_favorite_nonce" name="my_favorite_nonce" value="a87e4a44aa"><input type="hidden" name="_wp_http_referer" value="/markeim/properties/52-coles-road/"> <input type="hidden" name="form_title" value="brokercontact">
<input type="hidden" name="brokers" value="testemail#gmail.com">
<p>
Your Name
<span>
*
</span>
<br>
<input type="text" id="yourname" name="yourname" class="ink">
</p>
<p>
Your E-mail
<span>
*
</span>
<br>
<input type="text" id="youremail" name="youremail" class="ink">
</p>
<p>
Your Message
<span>
*
</span>
<br>
<textarea cols="" rows="" id="yourmessage" name="yourmessage" class="lab"></textarea>
</p>
<p>
<input type="submit" class="sending" value="Contact Broker">
</p>
</form>
It's something to do with your hidden input fields, not sure what. When I delete the nodes from dev tools and submit the form, it goes through fine!
Delete the hidden input field with name="brokers" and you'll see
I'm guessing WP uses the term "brokers" for something, please see here:
http://contactform7.com/faq/are-there-any-reserved-or-unavailable-words-for-the-name-of-an-input-field/