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.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Validation Function For All User Fields?
Hi, I'm wondering if anybody knows of a function or statement similar to perls read(STDIN, $input, $ENV{'CONTENT_LENGTH'}); to read in a forms content string so that I can manipulate each variable/value pair independently of their values. The reason for this is that I have a complex application form which has many inputs and I would like to put these values through a validation filter without explicitly naming them individually. My other option is to make an array of the variable names and use this in a for loop to go through each variable/value pair. This is fine but it would be handier to let PHP do that for me.
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?
Phone Validation On Multiple Phone Number Fields
I have an html form that gets processed by a "send.php" page. As you can see by my code below, I have a few different requirements for fields that need to be filled out and/or validated. I have been trying to add a simple phone validation. I can do it for one phone field, but I have 3 phone fields. I have a requirement to have at least one phone field required. However, I have not been able to find code to have it validate a phone number(s), and have it work with the "at least one field required" requirement. For example, if the user submits a home phone and a cell phone number, I need it to validate the format of the phone number (xxx-xxx-xxxx). If they submit it wrong, have it say "try phone number again" - but if they are right, then have it continue processing the form. Or, if they only submit the home phone, then only have it check that field, and not worry about the cell phone or work phone fields. Code:
Form Validation...
you would need to use Javascript for form validation, since the form is client side, PHP doesn't have the capabilities for validating forms to the extremes you'd need. it isn't all that difficult really, how well do you know Javascript?. if not well enough, contact me and i'll see what i can do.
Form Validation
Rather than individually access all the $_POST vars individually, I want to try and create a smart script, thats loops through all the fields and performs the neccesary checks. The problems being, depending on what var is being checked there will be different procedures, for example email username password etc etc Also, not all fields may be required, but some will be. How would you do this with a loop? Would you use a reg exp on the name of the var to determine what check to perform? So if it contained 'email' perform email check. If it contained 'pass' do the password check. If it contained 'numbers and letters' do the relevant check.
Form Validation - A Better Way?
I have a form to process in PHP, and I want to validate all the fields. only way that I can think of is use a if statement for each field, is there a better way than this? at the moment my code is just swamped with if statements...
Form Validation - How Can I Do This?
Can someone suggest a method or point me in the right direction for validating a simple form using php. I have a form which only has two significant fields - a drop down with three choices, and a dropdown with five choices - and I want the user to have chosen the correct value from the first dropdown before allowing the form to be submitted : ideally, on choosing the incorrect value, the page will display "incorrect please try again" or something along those lines. the form is like this :
Form Validation
Slowly I'm getting this figured out. Now I have the error messages going where i want them to but I cant figure out how to combine validation for different fields. The form due to how I now have it set up as error_msg, error_msg1 and error_msg2 will only reject the form if one field is not filled in. I tried to use the pipe to combine them but had no luck. Will i have to set a different complete validation for each field. Or can i use an array (error_msg = 'error messager here' error_msg1 = 'error message one here') somthing like that Can you use multiple words in an array? Everything i see on line and in my books show one word one=two sort of This is the code I now have ...
Form Validation
Many people often ask the question related to form validation. Here is my style. It just gives the idea; but not exactly what I do in development. <?php //usually header... ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML> <HEAD> <TITLE>Form Validation</TITLE> <META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <STYLE type="text/css"> <!-- p, input,select, table { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9px; } --> </STYLE> </HEAD> <BODY> <?php $tst_form = new TestForm(); if ($_POST) //form posted? { $tst_form->validateFormInputs($_POST); //extract inputs if ($tst_form->isValidInputs()).......
Form Validation
I am sure this subject has been done to death, but I would like to make sure that a form post is an interger or a float. I have used if (!ctype_digit($current_value) but this is true if the number contains a decimal point. I probably need a good tutorial/guide on form validation.
[php] Form Validation
I have a page now wich contains a form below that form are a couple of tables wich contain some data from the db. With the form you can add new stuff to that db. What I wanna do is make the form do self submit (no prob here) But now Im stuck with the way the script is going to work I want to validate the form and report back in text (on the same page) which fields were missing. If eerything is ok insert into db and just show the page.
Form Validation
I have been using JS for my form validation needs upto now but I have been noticing more and more problems with relying on this. Therefore I am now in the process of changing all this over to PHP, unfortunately I am stuck on how to check that the username field contains no spaces and that it is no longer than ten characters.
Form Validation
I need to validate the following fields using php. 1. email (needs to be just one e-mail address, and take out stuff like bcc or anything that would be used for e-mail injection vulnerability) 2. Phone number (has to be in the format 555-5555) 3. Phone number area code (has to be limited to 3 characters) 4. Address has to be stripped of all illegal characters like slashes, special characters etc Another thing is I don't want people to be able to leave any of the fields blank. Where does the validation code go? After this statement? if($REQUEST_METHOD=="POST") or before? I have tried a few things, but I am not sure what most people use,
Form Validation
I am having a break down in the "how to turn the page process. If a html form has the action attribute set to itself when the form is sumitted it validates (or not) then how does one get to the next page. I have a hidden variable - $validated but am a loss where to go with it. My code so far is based on a really sorry book "Professional PHP Programming" and it glosses over or simply dismisses big fundamentals.
Form Validation
I am a newbie to PHP and finding even the simple stuff quite hard. I am trying to validate an email address using a recursive page. The validation is done using a regular expression which works fine , and the valid/invalid messages shows as expected. My input tag is as follows: <input type="text" name="emailAddress" value="<?php $HTTP_POST_VARS['emailAddress'] ?>"> When the page refreshes the input field is blank! How do retain the value typed?
Form Validation
I am looking into form validation for my HTML form. I don't want to use javascript and was looking into using PHP. A crazy thought crossed my mind and I just wanted to get some input. What if I basically made the form one long if/then statement? I could ask for the first piece of information, test it against some conditions, then if it is okay I allow the user to fill in the next piece of information. I could go do down the page validation each box as we go. I could use hidden on all the text boxes until the previous condition had been validated. Some pseudocode: <?php <form action=POST method=registered.php> <input name"Fname" type="text"> if ($Fname meets some condition) { <input name="Lname" type="text"> if ($Lname meets some condition) { <input name="Number" type="text> if ($Number meets some condition) { } } } else; echo "Please enter a phone number"; else; echo "Please enter a valid last name"; else; echo "Please enter a valid first name"; ?> I know the code isn't exact, I am just theorizing here. Could such a thing be done? Even remotely similar? I don't really plan on doing this anytime soon, but I was just curious.
Form Validation
Ever get annoyed spending 90% of your time validating user input before processing/inserting into a database? I know I do. I was thinking of trying to write some framework that makes this process more generic and reusable. I'd also like to be able to share the same validation rules with javascript so that I don't have to write the logic twice. I was thinking define some sort of XML document with my validation rules and share that between PHP & Javascript but I see some limitations there as well. So my questions to you, fellow PHPers, do you see merit in this idea? Is it reinventing the wheel... what might be some existing solutions or frameworks that would be worth looking into?
Form Validation
I have a login form (though this persists with all forms). On my login.php page, if I use this code: if(isset($_POST['username'])){ 'do whatever here';} Once the form is submitted this always evaluates to true even if the field was left empty. I have used this: if($_POST['username'] !==''){ 'do whatever here'} A single space in the field will make this evaluate to true thus username field is no longer blank, but nothing was entered. empty() gives the same results as !==''. The only other way I can think of to ensure that something was entered is to use strlen() and make sure the fields are above a certain length. Does this sound plausible to anyone else, or is there a better way?
PHP Form Validation
I have an HTML for that I'm using to post data to a PHP validation script. I was then wondering if there is a way to pass the data from the post to another script without have the user to click submit on a form?
Form Validation
my httpd error_log keeps saying undefined index for each of the vars passed every time i try to submit. I can't find a syntax error in the code tho. Code:
Form Validation.
I am trying to validate a string for just numbers and letters... I can't seem to get it working. Not much of a fan of regex.. 0-9, A-Z, a-z <?php //This doesn't work.... if (eregi("/^[a-z0-9]+$/i", "test")) { echo "Valid";} else { echo "Invalid";}?>
Form Validation
I have a registration form (the bulk of it anyway) and all validation passes and throws up errors if anything doesn't pass. The last field is a text fiels so the user has to enter the captcha image and throws an error if they don't match. What I would like to know is, is there a way i can store the passwords if they match along with everything else when the validation has failed on the captcha text. It would be a pain for the user having to re-enter their password if they entered the wrong captcha text or is it common practice to leave them blank. Code:
Form Validation
I am having problems figuring out how to do a form validation using HTML and PHP. I create 2 radio buttons, 4 text boxes for name, email, password, and validation string. I then create some other stuff that isn't mandatory to fill out followed by a push button of type="submit". When the user presses the Submit button, I want to notify them if they forget to fill out the name, email, or password, or if they forget to choose one of the radio buttons or if they type in an incorrect validation string. I do not know how to go about doing this if it is part of PHP or HTML. Code:
Form Validation With JS
I read somewhere that it's a not faster to validate forms by with the client side (JS) and that PHP form validation should be used as backup. So I found some JS code to validate the form. Now, how would I proceed to validate the form with PHP in the case that a user turns off JS?
Form Validation
I wrote the following form so that if a user leaves a field blank the page will not process and instead be re-loaded with a red error message asking the user to enter the missing information: Code:
Form Validation
I have a script that validates blank fields, and improper entrys. I want to validate a couple of the fields (middle_initial,fax_number)for improper data, however it would be ok for them to leave it blank.
Form Validation....
Im in the midst of creating a secure signin script which brings me to two questions I have. 1. I want to filter out blank spaces from the login and password fields. Im very unfamiliar with regular expressions, so I went out and found the below script on the web: function no_specialchars($field1) { if (!eregi("[a-zA-Z0-9]+",$field1)) { $_SESSION['error'] = "The password or username fields should only contain alphanumerical characters or hyphens and underscores."; header('Location: reg_signin.html'); exit(); } } This function seems to do the trick when I try to signin with most special characters (although not all of them?!) and only spaces, however it still lets me pass when I put spaces before, in between or after the text string. What I want is to filter out any spaces and any special characters except for hyphens and underscores. 2. My second question would bring me to the handling of an error caught by the filter. Im using sessions where the session key 'error' is created once the filter finds a problem. This session data is then kept and displayed at the original signin form page. Is this the ideal way to do it or should I maybe put url variables to the redirect link such as header('Location: reg_signin.html?error=1'); and then read the user the error according to the error GET value?
Form Validation
Does anyone know anyway to put in additional php coding to validate list/menu in forms? I am currently using Dreamweaver, so I am using their Validation check in their Tags/Behaviour sections. I read in alot of places that this default function does not allow a validation check for list/menu. But I am wondering if anyone know of anyway to put in some additional coding so that it will allow it to validate the list/menu as well?
Form Validation
Does anyone know if it is possible to validate form fields (i.e. make sure certain sections ae filled in) with php? If it is can anyone tell me how or where I can find out how?
Form Validation
I've writen the script and it all works now I want to do some validation to make sure the user enters a 'correct value', simple enough you might think, anyway what I have is 40 fields in my form which are sent to 5 different arrays for processing, so: $q1 = $_POST['q1']; $q2 = $_POST['q2']; $q3 = $_POST['q3']; //....... //then $typea = array( '1' => $q1 , '10' => $q10 , '11' => $q11 , ........ '40' => $q40); //so now I want to validate... $check = 0; foreach ($typea as $key => $value) { if ($value != 0 || $value != 2 || $value != 3) $check = 1; echo $value . " , " . $check . "<br /> "; //to make sure values are what i think } if ($check == 1) //go back to form else //do the processing $check always returns as 1 though, even when the values are 0 , 2 or 3
Form Validation
I have a form that inserts data into a db via mysql. I want to validate the form to check people aren't inputting code to destroy my database and website. How can i go about this? Any good tutorials?
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?
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:
Form (Array) Validation
Okay i know i have been going on and on about this but its driving me nuts and i have confused a lot of people so i am going to paste code and comments. Hopefully ill get some help I have been working on these couple of scripts for a while. The first one you enter the number of textfields to create to insert images to the table. That actual field is validated (this works!) then it passes that number to second script which creates and array according to that number it got (this works as well !). Now before being able to submit the data finally (in page 2) i want to make sure that first there are no duplicates the fields are not empty (both dont work !). Some how with both or seperatley validations when i choose to submit i get the "Java Script Prompt" and when i click the OK button on the "prompt window" the page disappears !. Obviously when u (press back button) the fields disappear too since the arrays gone.
Form Validation With HTTP_GET_VAR [ ]
Hello, I am pretty new to PHP. I have set up this submit form which passes on many (around 30) variables, I want to make sure that all the forms are filled out and none of them are empty. Is there any way that I can use HTTP_GET_VARS [] so if any of the variables passed on are empty then the user will have to fill out the form again.
Form Validation Problem
I am using form validations for different fields. One of them for City as - if(($_GET['app_city']) == ''){ $cityError = "Invalid or missing city"; $error++; } else { $app_city = trim(stripcslashes($_GET['app_city'])) ; If I typed City as - "My City", If the validation fails, it shows City as - "My" instead. Does not consider both the words.
Validation After Form Submitting..
Basically, im redesigning a form page on our website. Currently the user submits the form, it does a few javascript checks and either submits to the "processstuff.php" page, or gives the user a JS error message.. where they have to go back and fill the details in. Im trying to optimise and make this form/page as best as it can be. Do you think it would be a better idea to continue using JS or use JS then submit to the php page(where it checks some other details(postcode validation) and submits, or just solely use php validation?
Form Validation And Setcookie
Is there a statement that allows for redirection to an entirely different page? What Im trying to do is have my script load a new page with SetCookie("UnderAge", "", Time()+3600); if a person enters an age under 13 years. On the main form page it would check for cookie(Underage) to deny them acces for an hour if set. Right now it simply echos "You must be at least 13 years of age to participate, you are not eligible." PHP Code:
|