Checking For Required Form Fields
i have written the script to check for blank form fields (all fields are required)
on my registration form using :
if (ereg(".", $first) == 1){
$verify = "OK";}
else{
print ("<b>ERROR:</b> A first name is required.");
$verify = "bad";}
my question is, although this script works to verify a form field, it doesnt prevent the incomplete form from being sent to the database. can someone tell me how to stop the form from being sent if it is incomplete, and should this script be included on the form page(html page) or the php page that submits the data to mysql?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
How Do You Get Required Fields In PHP
In HTML forms you use the 'required-value' to ensure that a field is completed before submission, is there any way to do this check in PHP? If so could you please give me an example or a link to where to find it.
Multiple Required Fields
I'm having trouble making a couple different types of fields on a <FORM> work -- when the form is processed, I have 2 types of fields I am trying to ensure the person clicks. If they don't fill out or click the appropriate field, the web page should notify them of this. name and address are simple fields where a person fills that in.ordertype is one of two radio buttons a person clicks on. I am detecting the fields that need to be populated, but cannot seem to detect when a radio button is not clicked on. Code:
Form Field *required* Validation
I have php form I'm trying to edit. Some of the fields on this form is required, and some aren't. I want to adjust it so none of the field is required. But I am not able to find the place to set this value. Following are 2 piece of the code for 2 fields, 1 is required and 2nd is optional. Please help me determin where I might be able to adjust the validation. Code:
Check Form For Required Details Before Mysql Insert
I'm making a script that will let the users of my site enter information into a form and then submit it to a database. I've created the database and set up an sql user account that's only allowed to insert to a specific table so that's all ok. The thing i'm having trouble with, is checking the required forms have been filled in. I don't need to do any reqular expression matches on any of the inputs, i just need to let the user know when they've missed out a required field and to stop the script if they haven't. I know this could have tons of different methods, i'm after something basic that will give me an idea how to do it as a beginner. Are there any turtorials or guides on the net that will give me the information i need? Oh, i'm aware the sql part of the code isn't complete. Please remember i'm somewhat of a php noob so go easy. Code:
Dynamic Form Fields/multiple Page Form?
It is for a friends out of print booksite, where visitors can request multiple books to be searched by adding one at a time to a cart (javascript), then once all added they submit to another form where they enter their personal details and all is sent through. The problem is at the moment they cannot change whats in the cart without refreshing the browser window and losing everything. 1) present for asking how many books they want to search for 2) display multiple rows of the same input fields depending on how many books they say they want to have searched for?i.e title|author|publisher|etc title|author|publisher|etc title|author|publisher|etc 3) when these are submitted they could see these above the next part of the form where they enter their details with the option to go back and delete/amend. 4) send all the info to my colleague. if so has anyone seen a similar script that I could take a look @ to see if I can hack it to suit my needs?
Process Form Fields
Hi, I need to process a generic html-form. Is there any way to access to the form elemts as an array?
Trying To Duplicate Form Fields.
What I would like is to when someone writes in one field. The same text is written in a seperate field. But without sending anything. all internally. Anyone have a clue?
Form Validation- One Of Three Fields
I've been looking for a PHP script to accept a search form for either the name or town or postcode fields to search a MySQL db. I would like the user to put in any one search field but not none. Also I am trying to figure out a select statment to select one item on a drop down form list or any item on the list eg the list would be dog, cat, horse, fish or all, the column would be pets. The search would pull out any single pet or all pets.
Populate In To The Form Fields
i worked on some programs that gets the datas from the user and insert them in to the database.now i want to retrieve the data from the database and i want them to populate in to the form fields.
Parse PDF Form Fields In PHP
I am trying to find out if it is possible to open a pdf file from within PHP, and parse its contents in order to extract all form fieldnames that might have been previously setup within the pdf itself. I want to find this out so that I can then generate a HTML form with all required questions, which when submitted, will generate a fdf / xfdf file, using the techniques from the following tutorial http://koivi.com/fill-pdf-form-fields/tutorial.php
Posting Form Fields
I have a form like the one below. Upon submit I would like to self post to the same page but have the original $_POST data( which was posted to this page from another ) also be sent along with the new form field data. How can I achieve that? Thanks. <form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']; ?>"> <table> <tr> <th><input type="text" name="fields[]"</th> .... <th><input type="text" name="fields[]"</th> <th><input type="submit" value="Add" name="add"</th> </tr> </table> </form>
Empty Form Fields
I have a simple HTML form, which when submitted I want to check whether he fields have been completed. If everything is complete, I want to process the form....No problem with this bit. If any of the fields are not complete however, I want to indicate this......for example by placing a * character next to the field which is empty i.e. echo "<TR><TD>Username</TD><TD><INPUT TYPE=text NAME=username></TD><TD>*</TD></TR>"; I am guessing that the best way to do this is submit the page to its self, and check for any empty fields, then display the form again. What would be an efficient way of doing this, given that I have to check about 20 fields?
Form Fields And Verification.
suggestions to with keeping data entered into form fields in place after verification fails and the user is requested to re-enter some missing data. Is there a smooth way to do this with PHP and forms, or would it be best to try and use javascript for a form, so when the "back" button is hit the data is remembered?
Hidden Form Fields
i want to output the value of the "hidden form field". When I hit submit, the the value is put to the hidden form field. when I hit the submitbutton a second time the value of the hidden field is dispalyed. Is there a way to display the value on the first submit Code:
Getting HTML Form Fields
I'm trying to figure out a way to get the values of input fields from a HTML form, and place them in a database. For example if a html form had 3 text boxes one for "name" one for "email" and one for "url" how would I go about getting those values? I also need it to grab the values from hidden form fields, is there such a function or class? I know it will prob have to entail some regular expressions, but as I'm not too familiar with regxep could someone take a stab at it? Also any good tutorials on regexep would be nice too.
Validating Form Fields
I would like to create a php script that can validate all of the required elements in the form. I'm not sure the best way to do this, but I know it's a smart idea to have good validation in place before there is a problem. There are a few pages involved here, and the ACTION tag in the form is sending it to an email delivery script, so it needs to be as error free as possible. In this case would it be smarter to create inlined code that will validate the fields based on an if/else statement before the form is posted? If someone could give me a sample code of what a simple form field validation would look like that would be great. PHP Code:
Add Fields To A Form Dynamically On The Fly
I'm looking to create a form the allows the user to input a simple list item by item. However I am not sure how to implement a form that allows the user to add as many fields as the need on the fly.
Dynamic Form Fields
I want to have it setup so when the user clicks this link a value is sent via get and that value is put through a for loop to generate an additional form field: Code:
Checking Form Contents
I would like to verify the contents of a form before inserting the data into a mySQL database. How can I check the contents of the form and return the user to the form if they have not completed all the required fields(with the data they have entered intact). Only after the form is verified to contain all the mandatory data do I want to insert it into the database. In addition, it would be great if I could highlight the fields that are missing data. Currently, I have a php script handling the submission and insertion. Is it possible to make that submission conditional?
Checking Form Input
Well i've eventually manage to get a comments system working on my site, adding information etc. however i want to add a few saftey precausions. I.e prevent use of HTML commands been enterend into a comment or holding down a single key, that can often lead to tables been pushed out of size, thus messing up the site. i have been using a function that strips out swear words, this works fine, I included an option to remove HTML etc... using PHP Code:
Want To Autopopulate Form Fields From Database
I have a working form that submits info into a database. I want to take a few fields about the poster (name, email) and hide them and have them filled out from my user table, which is the same database but different table then where the form data is being sumbitted. I must be searching for thr wrong thing cause i am not finding any information on it.
POST Blanks Out Form Fields
I have a form that POSTs to itself and validates data entered into the form. If all is well the form performs a header location command to move to the next input form in the series. If the user has entered an error within the form the user is NOT redirected to the next page and error messages are displayed indicating the fields that are in error. So far so good. The only problem is that all the input fields are now blanked out after the post. These fields must display all the values that were inputted before the post was executed. I have tried the following to no avail...... reassigning values like this after the post => $zip=$_POST['zip']; reassigning values like this after the post => $fullname=$_SESSION['fullname']; Utilizing this Meta Tag => <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="CACHE"> How can I keep the data that was entered into the form fields before the post was executed?
Hey Need Help With PHPMailer And Checkbox Form Fields
I need to be able to send an attachment for each checkbox the user checks. like this: <input type="checkbox" name="file" value="bob.amr"> I need to have multiple checkboxes! and if they are checked the user gets an attachment for each? I am using the popular PHPMailer!
How Could I Get The Form Fields Filled From A Database?
One idea I have is to do a redirect, but it doesn't quite work because it ends to an infinite loop cause the page is redirecting to itself: header("Location: " . $_SERVER['PHP_SELF'] . "?field1=something&field2=something else"); That would bee neet. I just would create a string from the contents I receive from the db and just redirect, but as I said, it doesn't work easily. You have to use the apache rewrite, but I didn't quite get it. Another solution is to check if the request is not empty for the particular field.
Spell Form Fields Using Google API?
has anyone produced spell checker code for forms fields that uses the google API? WHat about any GNU spell check that does NOT use aspell/pspell/ispell?
Duplicate Input In 2 Form Fields
Hope to check the input in two form fields: input in "emailto" form field: a@a.com input in "emailfrom" form field: a@a.com, b@b.com, c@c.com I hope to remove the duplicated input "b@b.com" in "emailfrom" form output and then keep only the remaining part of the string. How can I do that? I have though a way in combining the two fields input as an array and then use "array_unique" to check the duplicate. And then, to separate the two fields input again.
Having Dependant Form Fields (comboboxes) From Each Other?
I am currently programming on a form with 2 combo-boxes for input. But I need the box 2 output be dependand on box 1 input. I will explain in more detail: I have a SQL table that has 3 columns. One for type, second for motor and third for defining. By PHP I have output all types (cars and bikes) in the first combobox. Now what I need is, how can I manage, that when a person chooses e.g. in box1 Mercedes (which is defined in the 3rd sql column as a car) it would only show in the combo-box 2 of my form those motors that fit a car WITHOUT reloading? I kinda simplified things here a little, but what I described above is the main problem I have. Somehow it must be possible through javascript I guess to check the value in combobox1 get the 3rd columns value of the mySQL table probably by PHP before, and then check IF that value is car then show only certain motors and IF that value is bike show other motors.
Defaulting Data In Form Fields
in a lengthly form, is it possible to use PHP3 to automatically fill form fields with data that has already been entered into a previous place on the same form?...or from a previously filled out form?..likewise, is it possible to perform a math calculation on a number entered into a field and have the result automatically defaulted to another subsequent field?
Omitting Form Fields If Empty
I have a form I'm putting together. The processing will be on a PHP script that will take all the field names and print them out on the email it sends to me. No problem there. But what I'd like to do is have it exclude printing the field name and value when there are any blank values in the field. The processing part of the script is this: if (is_array($val)) { for ($z=0;$z<count($val);$z++) { $content .= "$key: $val[$z] "; } } else { $content .= "$key: $val "; } How would I adapt this to not print a field name with a blank value?
Sticky Form With Multiple Fields
how do i create a sticky form with multiple fields? say i want a form with: name: [input field name] address: [input field address] country: [input field country] [submit button] and if a user presses the submit button it will show exactly the same page with the fields that the user has entered filled in with the values (s)he entered (validation of the values will come later), and the info of the form sent. should i name all the values in the form separately or should i use an array?
Enter Data Into PDF Form Fields
Is it possible to use PHP to fill in fields in a PDF form? The form can be found at :PDF form The background to the question is that I have a client who has a debt collection database system written in DataEase that ouputs County Court Summons data on to Court Summons Stationary. This is hit and miss on the printing margins depending on OS system or printer. The system is being written in PHP so the summons forms could be produced in HTML if the existing PDF form isn't a viable solution.
Passing Hidden Fields In A Form?
I'm wanting to take information that is put into a hidden field by a sql query and post it to a script...I have a page that lists the players(nfl), in a table, for each persons team. beside their players name on their roster is a dropdown menu that has starter and bench. these options both have values. then i also have hidden fields with the players names. what i want to do is be able to apply whatever option is selected in the table to the hidden fields so they can be passed to the script. if anyone has any better ideas i'm open.
Form Fields To Update A Webpage
I am trying to build this mini "publishing" system and allows the user to use form fields to update a webpage (images and text) then press a button to email that webpage to a list of emails. (spamming own userbase). I will have a webpage with php code in it and the code will pull data from the db. How can I save the file has a static html file so that I can pass it to my mail function? or can I directly pass the php page to the mail function? or what is the best way of doing this? I also have to learn how to do file upload with php aswell.
Populating Form Fields With Variables
The script itself works fine: mail gets sent. If there are any missing fields the form displays again with a list of the missing fields, but I can't get the form fields of the reloaded form to be populated with teh existing values. PHP Code:
Check For Empty Form Fields
I am just starting with php (like 2 days now) and was wondering what was the best way to check for empty form fields. The code I am currently using is below but I was wondering if there was a better way to do it. Also I would like to know if my code structure/layout is ok as it is important to me to get off on the right foot. PHP Code:
Identifying Dynamic Form Fields
User goes to page which is a form that asks for some basic info regarding returning products for credit/exchange, and also asks for how many products are going to be returned. Upon submitting, a return authorization form is presented to them with the specified number of product fields. I now want to take the input from this form and email it to myself, as well as, display a confirmation page to the user. The problem I have is a can't say, for instance, echo "$field_name"; because field_name will get created dynamically after the user specifies how many products to return. For example, say the user says 5 products, this will generate a form with field names like: return_code0 inv_num0 qty0 product0 cre_exch0 stockout0 return_code1 inv_num1 qty1 product1 cre_exch1 stockout1 return_code2 inv_num2 qty2 product2 cre_exch2 stockout2 and so on.... These get created with a for() loop. Once this form is submitted, how can I address the field names? Code:
How To Validate Contact Form Fields?
I was just wondering how to make my contact form recognize if the user has actually entered any information into the fields. Right now if the user just clicks submit then an email will be sent to me without them having to enter any info into the fields.. Please can someone tell me how to prevent this? I would also like to know how I can filter the message field from letting the user enter in profanity? Code:
Form, Posting Multiple Fields
I have a product list page, users can check the product then go to an e-mail form, that lists the products they checked. On this, they can then chose a quantity for every product, how do I make it so when they send the e-mail, it gets the quantity for each product (using PHP mail, to send)? The field would be: <input type="text" size="4" maxlength="4" value="1" name="quantity"> But that wouldn't work for multiple ones? Would I use a "foreach" statement, somehow?
Eregi Validate Some Form Fields.
I'm working with eregi to validate some form fields I dont understand what this stuff means. "eregi('^[a-z]{2,30}$', $name)" Can someone break this stuff down "^[a-z]{2,30}$" so I can understand it.
Form Input Error Checking
Have a form field being inserted, needs to only allow an integer value through. Which function do I want to use to check the passed var to see if there are any non-integer values present? PHP Code:
Checking If A User Has Submitted A Form
I have a form that validates itself by putting "<?php $_SERVER['PHP_SELF'] ?>" as the form's action. I have now written some simple validation, shown below. $name = $_POST['name']; if (!isset($name) || empty($name)) { echo "Error, please fill in the name textbox"; } The problem is, this code shows up, even if the user has never submitted the form. How do I only show the error AFTER the user has pressed my submit button?
Losing Posted Form Fields Over Https
This has been driving me nuts. I have an application running for several clients. Some run on http and two run on https. Two weeks ago, the https customers started occassionally getting kicked out to the home page. This is not every time, it's generally 1 in 10 form posts. Refreshing the page asks you to repost the info and it posts as it should have in the first place. Dumping the $_SERVER variable shows me that if things go well I get the $_POST and $_GET variables and the $_SERVER["CONTENT_LENGTH"] is a number. When the error shows up, CONTENT_LENGTH=0 and there are no $_POST or $_GET variables. I can only reproduce this over https on Linux/Apache/PHP using Internet Explorer. I cannot reproduce it using Mozilla or Opera as a browser. And I also can't reproduce it using IE over https with Windows/IIS/PHP. None of the PHP code changed and there were no new installations on the server I can point to as a possible cause. We were running PHP v4.1.1 and upgraded to v4.3.4. I have been able to trap the condition to offer our users a page to inform them to refresh so they won't lose their data. Any suggestions, ideas, places to look or ask more questions, is much appreciated. $_SERVER[SERVER_SOFTWARE] => Apache/1.3.20 Sun Cobalt (Unix) mod_ssl/2.8.4 OpenSSL/0.9.6b PHP/4.3.4 mod_auth_pam_external/0.1 FrontPage/4.0.4.3 mod_perl/1.25
Mail Function & Multiple Form Fields
I'm having some problems with a php mail form where I am wanting to send information from 10 form fields in a e-mail. the way I have it structured for the mail command is mail ($to,$subject,$message); where message is made up from the multiple fields from the form e.g $message = "Name: ".$strName." "; "Company: ".$strCompany." "; The e-mail is sent fine but it only gives me the persons name and not the extra fields. Can anyone point me in the right direction?
Best Way To Create Object From A Form With Lots Of Fields
I have multiple forms that will create an object. Basically a energy efficiency measure object. The measure object will have a couple of required properties set but after that it can have 10-20 different fields that are optional per measure. How do I account for the different fields that will be posted from the different forms when I create the measure object? Should I create a constructor method with just the required fields as the parameters and then create some sort of setter method for the optional fields? Or do I create a different concrete measure object from an an abstract measure base class? I have about 10 different measure objects that I can think of but really the only difference between them are what optional fields are posted. Going forward the other issue is I need these measures to persist across the pages of the application (sort of like a shopping cart app) and I see that I can serialize an object in a $_SESSION object but do the fields that I would set in the setter method also get serialized or do only the actual properties of the object get set. I then need to retrieve all these measure objects and send them to a stored procedure to enter into a database so unfortunately I can't save the fields as serialized because each field has to be separate to be sent as the parameters to the stored procedure. Basically my question is how do people deal with huge forms and fields easily from a html post?
Reading Form Data In Fields Are Unknown
I have a project where the users can modify their forms and thus their form field names. Is it possible to simply read what is passed through the headers without knowing the names of the fields.
|