Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




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?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
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?

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:

Empty Fields For Every Record
If i have a table structure like in my attachment, how can i check for empty fields.That is, I want to check for every record in the table if lastname, street, zip, city and pwd are filled.

For example, in the second record that is with id no:2, street and city are empty.Similarly for the next record with id no:3, lastname,zip and pwd are empty.

So, idno:2 and idno:3 are incomplete.
Now, what i would like to do is, if i press a button, i want to send an e-mail to the respective e-mails which are in idno:2 and idno:3 that they need to fill their information again.

Could somebody please tell me how can i do this one?

Empty Fields In Forms
I'm working on a script for a form for people to submit their info ( Name, e-mail, AIM, website URL etc). Now it is possible that some people don't have AIM or a website. I'm using a html table to display the info on the member page and empty fields make the table look strange. Is there a way to set some default value (like N/A) that would be displayed in case a field is left empty?

How To Check Empty Fields
If i have a table structure like in my attachment, how can i check for empty fields.That is, I want to check for every record in the table if lastname, street, zip, city and pwd are filled. For example, in the second record that is with id no:2, street and city are empty.Similarly for the next record with id no:3, lastname,zip and pwd are empty.

So, idno:2 and idno:3 are incomplete. Now, what i would like to do is, if i press a button, i want to send an e-mail to the respective e-mails which are in idno:2 and idno:3 that they need to fill their information again.

Display Empty Fields?
i've got some empty entries in my database. i'm trying to avoid displaying entries that have no value in them. they are not null entries though. i tried something like this but got an error message. i can't remember the exact error messaage now as i am using another PC away from home.

if (some_array[some_field] != ""){
do something}

it checks to see if the field is empty or not. if its not empty, it'll print something there.

Finding Empty Fields
Am trying to get from a table which row has an empty field. PHP Code:

Throwing Empty Fields Out Of An Array
what is the best way to throw out empty fields from an array i mean, if i have an array looking like:

array[0] = house
array[1] = NULL
array[2] = car

i whant the array[1] to be taken out, so it looks like:

array[0] = house
array[1] = car

Select Count But Exclude Counting Empty Fields?
Hi, any pointers on how I can exclude counting any instances where a field is empty? i.e I have

$sql = 'SELECT count(reviewid) as num_times FROM reviews WHERE reviewid =' . $id;

I use this to get an average. But some times the average field is empty. So in the above I want to exclude it counting where the average is blank.

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?

Empty Form
Say I have a form, a really long form, is there a way to check if all the fields in the form are empty without saying a million if statements?

Best Test For Empty Form Value ?
What's the best way to test for an empty form value ? I am doing it like
this now:

$test = $_POST['inputTest'];
if(strlen($test) < 1)
// it is empty !

Maybe I can just go:

if($test == '') // that's two single-quotes with nothing in between
// it is empty !

At least I avoid a function call that way. Maybe there is a better way ?

Empty Value In A Form Dropdown
Think that we have one dropdown form where we can choose countries from like this.

<select name="country" id="dropdown">
<option value="Choose country">Choose</option>
<option value="USA">USA</option>
<option value="CANADA">CANADA</option>


IF I have an SELECT I can easily set country = '$country' IF user have choosen some country, but when user not choose any country the selected one is "choose", is it possible do add All countries to $country so the SELECT formula include all countrys and not just get empty? 

When A Value Passed In Form Or Q'string Is Empty..
I am trying to figure out how to deal with when not all elements
in a submitted form are filled out or when page expects a query string
and doesn't get one.. I tried the two conditionals below, but still got
errors:

$param= $_GET['msg'];

/*
if ($param != "") {
echo $param;
}
*/

if (isset($param)) {
echo $param;
}

query string is:

home.php?msg=selected records have been deleted from the database.

(referrer pg is not always pg sending query string.. so need to deal
w/when no query string is passed..)

Show If Form Varible Not Empty
I need an alteration to my code to show region only if the form varible from the previous file is not empty.

I have a list of properties in a table called employees, database name gcproperty.
Some properties dont have full records in the fields (photo1, photo2, etc..........to photo9. and are empty.

On the show all details page some images are blank as there is no record in the database or where drawn from the form varibles browse page that where also empty.

Does this make sense? Code:

Firefox Causing Empty PHP Form Variables??
This is really weird, and I would never believe it possible if it
weren't actually happening to me.

I've a customer database in mySQL, using PHP to create the forms, yadda
yadda.
All of a sudden, every time I edit a customer, when I submit the form
using Firefox 1.0.2 on Linux (Fedora Core 3) it sends empty form fields
to the database.

BUT, if I use Firefox on Windows, or Opera on Fedora Core 3, it works
perfectly fine.

Any ideas what in the world could cause this?
Firefox on Linux worked fine to up until...the last few days I think.
The only think I can think of, is I may have installed a couple of
extensions during that time.

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.

Fill In Form Fields On PDF
Looking for classes or libraries which allow you to fill in form
fields on a PDF document.

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>

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:

Cannot Read Information From Form Using POST Or GET ($_Post Is Empty)
I am having problems in my php code. I am relatively new to php but I
know some basics.

This is the problem:

when i try to echo some information that is typed into form back to
the screen i get absolutely nothing. It seems like $_POST['name'] is
an empty string, along with $_POST and $_GET['name'].

I looked around to see if someone else had the same problem and found
that some people's code didn't work because of IE6. but i also tried
mine on Netscape and i got the same problem.

So why is $_POST empty after posting information. Even $_GET was
empty.

all of those returned empty

echo $_POST;
echo $_POST['name'];
echo $_GET['name'];

here is the code:
the code was originially meant to send an email but i commented the if
statement out to see why it wasn't working

<html>
<head><title>Feedback</title></head>
<body>

<?php

// Handle POST method.
//if ($_POST)
//{

$name = $_POST['name'];
$email = $_POST['email'];
$comments = $_POST['comments'];

// Compose simple text message:
$message = "Message from $name
($email)

Comments:

$comments";

// Send message to bob@microsoft.com
mail("email@email.com", "Feedback", $message);


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.

Form Fields Not Carrying Data
I'm having a problem with the following form; Code:

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?

Form Fields Not Submitted In Php. Any Gurus?
None of the variables passed thru the HTML files once filled are displayed in the process.php

I checked my PHP.ini file it says register_globals=On ....

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.

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?

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?

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:

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?


Copyright © 2005-08 www.BigResource.com, All rights reserved