Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a site that has multiple ways to access our "email me for more information" form.
On the form, it has a list of checkboxes that they can check that they want to be emailed about more information for. Is it possible to have the check box prechecked depending on what page they come from?
For example, they visit our "Product 12" page and follow the link to the form and there is a checkbox to receive more information on Product 12 that is pre-checked because they came to the form from the Product 12 page.
Here is my form code:
<form id="formElem" name="formElem" action="" method="post">
<fieldset class="step">
<legend>Personal Details</legend>
<p>
<label for="fullname">Full Name</label>
<input id="fullname" name="username" />
</p>
<p>
<label for="company">Company Name</label>
<input id="company" name="company" />
</p>
<p>
<label for="title">Title</label>
<input id="title" name="title" />
</p>
<p>
<label for="phone">Phone Number</label>
<input id="phone" name="phone" />
</p>
<p>
<label for="email">Email</label>
<input id="email" name="email" placeholder="info#.com" type="email" AUTOCOMPLETE=OFF />
</p>
</fieldset>
<fieldset class="step">
<legend>Products I'm interested in...</legend>
<p>
<input type="checkbox" name="telematics" value="telematics">Telematics<br>
</p>
<p>
<input type="checkbox" name="controllers" value="controllers">Controllers<br>
</p>
<p>
<input type="checkbox" name="cots" value="cots">Custom-off-the-Shelf<br>
</p>
<p>
<input type="checkbox" name="displays" value="displays">Displays\Operator Interfaces<br>
</p>
<p>
<input type="checkbox" name="cordReels" value="cordreels">Cord Reels<br>
</p>
<p>
<input type="checkbox" name="pdm" value="pdm">Power Distribution Modules<br>
</p>
<p>
<input type="checkbox" name="rtc" value="rtc">Real Time Clock<br>
</p>
</fieldset>
<fieldset class="step">
<legend>Services I'm interested in...</legend>
<p>
<input type="checkbox" name="productDev" value="productdev">Product Development<br>
</p>
<p>
<input type="checkbox" name="desEng" value="deseng">Design Engineering<br>
</p>
<p>
<input type="checkbox" name="dfx" value="dfx">DFX<br>
</p>
<p>
<input type="checkbox" name="transServices" value="transServices">Transition Services<br>
</p>
<p>
<input type="checkbox" name="stratSourcing" value="stratSourcing">Strategic Sourcing<br>
</p>
<p>
<input type="checkbox" name="planning" value="planning">Planning<br>
</p>
<p>
<input type="checkbox" name="manufacturing" value="manufacturing">Manufacturing<br>
</p>
<p>
<input type="checkbox" name="fullfillment" value="fullfillment">Fullfillment<br>
</p>
<p>
<input type="checkbox" name="prodLifecycle" value="prodLifecycle">Product Life-Cycle Management<br>
</p>
</fieldset>
<fieldset class="step">
<legend>Confirm</legend>
<p>Everything in the form was correctly filled
if all the steps have a green checkmark icon.
A red checkmark icon indicates that some field
is missing or filled out with invalid data.
</p>
<p class="submit">
<button id="registerButton" type="submit">Register</button>
</p>
</fieldset>
</form>
The serverside code will be PHP.
Plz respond.
If I was in your shoes, I would use a query string variable to pass the ID of your page (or product ID would be ideal) on the link linking your product page to the form.
ie.) /formPage.html?id=12
On the form page, give each input element a unique ID. Then using either server side code or javascript, check if the id is present in the querystring, if so, check what it is and programatically check your checkbox.
It's easy with jquery:
$("#product12ID").prop("checked", true); <---- This will check the checkbox that has an id=product12ID
It would be helpful to know what language you're using (ASP.NET, PHP, etc). It would help fine tune what direction to go in.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 9 months ago.
Improve this question
I try to upload a Image by using PHP. I need to save image in my database. this is my HTML file. I dont know how to pass data file
<form action="insert.php" method="post">
<p>
<label for="firstName">First Name:</label>
<input type="text" name="first_name" id="firstName">
</p>
<p>
<label for="lastName">Last Name:</label>
<input type="text" name="last_name" id="lastName">
</p>
<p>
<label for="Gender">Gender:</label>
<input type="text" name="gender" id="Gender">
</p>
<p>
<label for="Address">Address:</label>
<input type="text" name="address" id="Address">
</p>
<p>
<label for="emailAddress">Email Address:</label>
<input type="text" name="email" id="emailAddress">
</p>
<input type="submit" value="Submit">
</form>
Use enctype='multipart/form-data'
<form action="insert.php" method="post" enctype='multipart/form-data'>
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/
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I've got a form with 6 inputs of different types (select, radio, text...). When I debug with Xdebugg I can see the values in $_POST variable,
I've decided to add other input but they arent posted : when I look at $_POST variable, I just have the first 6 values.
Here's a part of my form :
edit : i've copy/paste the code this time. My boss told me to not send the real code, that's why I've send a fake code but i really need some help so here's the real one.
<div id="modifierUser" class="divAdmin">
<form id="modifierUserForm" name="modifier_user"action="includes/inc_adminModifierUser.php">
<fieldset>
<legend>
<img src="img/bulle_48.png" alt="bulle" title="bulle" />
<h3>Modifier le compte</h3><br />
</legend>
<!-- the field i've tried to add -->
<label class ="labelEmail" for="idmembre">ID du membre </label>
<input id="idmembre" name="idmembre" size="35" class="required"/>
<!-- -->
<label class ="labelEmail" for="pseudo">Utilisateur </label>
<input id="pseudo" name="pseudo" size="35" class="required"/>
<label class ="labelEmail" for="anneeNaiss">Année de naissance </label>
<input id="anneeNaiss" name="anneeNaiss" placeholder="e.g : 1984" size="35" class="required" maxlength="4" value="" />
<label class ="labelEmail" for="email">Email </label>
<input id="mail" type="email" name="email" size="35" class="email" value="" maxlength="50"/>
<label class ="labelEmail" for="telephone">Téléphone</label>
<input id="telephone" type="tel" name="telephone" size="35" class="required" value="" maxlength="10" />
<label class ="labelEmail"> Masquer numéro dans l'annonce</label>
<input type="radio" name="masquerTel" value="oui" id="oui" checked="checked" />
<span>Oui</span>
<input type="radio" name="masquerTel" value="non" id="non" /><span>Non</span>
<label class ="labelEmail" for="region">Région</label>
<select id="region" name="region" size="1" class="required" style="width:180px"
<option value="Aquitaine" selected="selected" >Aquitaine </option>
<option value="Alsace">Alsace </option>
<!-- There's many options there-->
</select>
<input type="submit" name="enregistrer" value="Enregistrer les modifications" size="35"/>
<input type="button" name="annuler" class="annuler" value="ANNULER" />
</fieldset>
</form>
</div><!--fin modifierUser-->
variable i can see :
$_POST['pseudo']
$_POST['anneNaiss']
$_POST['email']
$_POST['telephone']
$_POST['masquerTel']
$_POST['region']
i'll always have $_POST[6]in xdebug, no matter how many input i add. But i tried to suppress one of 6 above input and i got $_POST[5].
The one I need to see
$_POST['idmembre']
Sorry for wasting your time
It looks as if the values aren't being posted because you've mispelt "action", calling it "ation" in the form element starting tag. <form>.
Because of this your form will be posting to the same page it's output in, rather than the page you're trying to POST the data to.
The first line of your code should look like this instead:
<form id="modifyUserForm" name="modify_user" action="includes/inc_adminModifyUser.php">
it seems that you have an extra double quote in your code so thats normal you HTML code does not render correctly:
<input id="inp_realname" name="realname" size="35" "/>
should be:
<input id="inp_realname" name="realname" size="35" />
I have a html form which posts to a php script. It works fine in chrome and firefox but not in IE. I have ran a test on W3C but can not find any errors that relate to the form. My code is:
<form class="formular" id="formular" method="post" action="script/contact.php">
<fieldset>
<label>
<span>Name : </span>
<input type="text" class="validate['required','length[3,-1]','nodigit'] text-input" name="Name" />
</label>
<label>
<span>Email address : </span>
<input type="text" class="validate['required','email'] text-input" name="email" />
</label>
</fieldset>
<div class="button">
<input type="submit" value="Contact" class="submit" />
</div>
</form>
Thanks in advance
Form is correct. Looks like wrong handling form on server side. how you catch result?
I have set up a PHP form for a competition for users to enter all information to be stored in a database. I used a NetTut+ tutorial to do so.
I've got the form submitting to the database as required, but with so many additional questions being asked, I would like to split the form into two separate sections. Obviously the first page would say continue to the next step before the second step allowing for the form to be submitted to the database.
The content that the user sees should be split, but should all be a part of the same form. Step 1 > Step 2 before submission.
Would anyone know of or recommend any methods to do this?
I've attached the code below.
<form method="post" action="">
<fieldset>
<ul>
<li>
<label for="code">Entry Code On-Pack</label>
<input type="text" name="code" />
</li>
<li>
<label for="name">Name</label>
<input type="text" name="name" />
</li>
<li>
<label for="email">Email</label>
<input type="text" name="email" />
</li>
<li>
<label for="addressone">Address</label>
<input type="text" name="addressone" />
</li>
<li>
<label for="addressone"> </label>
<input type="text" name="addresstwo" />
</li>
<li>
<label for="addressone"> </label>
<input type="text" name="addressthree" />
</li>
<li>
<label for="telephone">Telephone</label>
<input type="text" name="telephone" />
</li>
<li>
<label for="dob">Date of Birth</label>
<input name="dob" type="text" value="[dd/mm/yy]" />
</li>
<li>
<label for="q1">Where have you seen Cookstown advertised?</label><br />
<input type="checkbox" name="q1cb1" /><label for="q1cb1">Magazines</label><br />
<input type="checkbox" name="q1cb2" /><label for="q1cb2">Billboards</label><br />
<input type="checkbox" name="q1cb3" /><label for="q1cb3">Television</label><br />
<input type="checkbox" name="q1cb4" /><label for="q1cb4">Radio</label><br />
<input type="checkbox" name="q1cb5" /><label for="q1cb5">Online</label><br />
<input type="checkbox" name="q1cb6" /><label for="q1cb6">Public Transport</label><br />
<input type="checkbox" name="q1cb7" /><label for="q1cb7">Bus Stops</label><br />
</li>
<li>
<label for="q2">How well do you remember those advertisments?</label><br />
<input type="radio" name="q2" value="VeryWell"/><label for="q1cb1">Very well</label><br />
<input type="radio" name="q2" value="FairlyWell"/><label for="q1cb2">Fairly well</label><br />
<input type="radio" name="q2" value="FewDetails"/><label for="q1cb3">A few details</label><br />
<input type="radio" name="q2" value="NotAtAll"/><label for="q1cb4">Not at all</label><br />
</li>
<label for="tc">Do you accept the terms and conditions</label>
<input type="checkbox" name="tc" class="styled" />
</li>
<li> </li>
<li>
<input type="submit" value="Enter Competition" class="large blue button" name="signup" />
</li>
</ul>
</fieldset>
</form>
Use sessions mechanism to store 1 step data
You could pass them to page two and then put them in as hidden variables. You could also use session variables.
example with hidden fields
Sessions are usually the preferred way to do this, but hidden form fields would work just as well.
It's pretty easy to do - after the first submission, store the values into the session - validate them first if you like, it's probably a good idea to do so in fact. Then go to the next page, and once submitted, validate the second bunch of answers and put them into the database.
Hidden form fields work too, but I prefer the session-based approach.
Good luck!
One other option would be to put the additional fields in a hidden div on the same page and use javascript to show them once the first set have been completed. The advantage for you is that it keeps your form processing simpler. Also for your users, they won't have a round trip to the server to get the other part of the form.
This, of course, requires that your users have javascript turned on. The best practice would be to show all fields on the same page by default, and then use JS to hide the second batch before the page renders.