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


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Dropdown Box Form Validation


I am doing a form validation i php in that one of the fields are dropdown box this is compulsary field by defauly users can see "select from the following optios. i am trying the following code:

if ( $_POST['optio'] == "" || ereg("[^50_late|50_new|50_old|25_best|25_mike]", $_POST['optio']) )

but the above validation will work only text area if that is empty it will give error this error i can print using print but i am not sure how to validate the dropdown box options if the didn't choose any of the fields i will disply error.




View Complete Forum Thread with Replies

Related Forum Messages:
Dynamic Dropdown And Hardcode Dropdown In Select Form
I have plenty of examples of dynamic dropdown choices but none of hardcoded dropdown choices. The ultimate goal is to have a job with various tasks and to track the status of those tasks for a given job. I've used one of the tutorials here to begin the process. Below is the code I have to add work on a given task. Perhaps I actually need to "Update" a job as opposed to "add".

But the problem of the moment is I can't seem to hardcode one set of my options. This is the code I have: PHP Code:

View Replies !
Form Validation :: Combine Validation For Different / Multiple Fields
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 ...

View Replies !
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? 

View Replies !
MySQL, DropDown, PHP, Form!
Well I have this mysql database with some passwords. Now I have a form where a dropdown list is populated with the name of the users (there are repeated names).

Well what I'm trying to do is after selecting an user in the dropdown list, the post will be directed to a result form where I'll have again the name of the user and now his password (for that exact row). Code:

View Replies !
Adding A Dropdown To A Form From A Db Table
What i'm trying to accomplish is to have my html form have an element that includes a dropdown menu that's fed from a list of names from an existing mysql db table. Code:

View Replies !
Form Dropdown Issue With Firefox
i've been using on a number of my sites works both in IE and firefox but for some reason I moved the code to another site i'm working on and it only works in IE now.......Well I've never actually used it for remote urls just local so this may be my problem. Code:

View Replies !
Form Validation For A Simple Contact Us Form
I'm doin a Web Programming Course and we were asked to do a simple contact for. for some reason it's not running. Can someone tell me why? here is the code:

<?php
IF(ISSET($_POST['submit'])){
$NAME = $_POST ['name'];
$EMAIL = $_POST ['email'];
$SUBJECT = $_POST ['_subject'];
$MESSAGE = $_POST ['message'];
include 'config.php'

View Replies !
Dynamic Fill Form Fields Depending On Dropdown Box
This question has probably already been asked, but let me ask again

I have a mysql database to which I connect with my php scripts. The
database contains articles. Name, Unit_Price and Reference

Now my client needs to order 5 items, click a button and a table with 5
lines and 3 columns appears (until now easy)

In the first column is a drop down box with a <select > and <options> in
which I store all possible names.

I would like than whenever the client changes one of the boxes (in my
case there are 5) the Unite_Price column and Reference column in the
line he just choose get automatically updated

View Replies !
Data Entry Form With Dynamic Dropdown Boxes
I am working on a Form for user to register & enter their info such as name, email, address, tel etc. and I put in a couple of dropdown boxes namely country and city where user can select. I made them dynamic, i.e. the city dropdown is based on the selected value from country and the data retrieved from MySQL database.

The problem I have is the Javascript script involved a reload of the form and once I select a value from Country, the city dropdown populated with data OK but the data entered beforehand (Name, email, etc.) disappeared.

View Replies !
Validation Form Redirect To New Form
I have a validation form that must behave differently based on the results of a PHP validation check. I have a post command at the top of my form that calls itself. I don't leave the form when performing the validation check on the values that were entered into the form, I simply repost the form to perform the PHP validation. If any of the values that have been entered into the form are incorrect, I display a warning message on the screen for the fields that are in error. This works fine.

However, if all the values that have been entered are "correct". I want the form to open up "another" form without reposting to this same form. So, after I perform the first post that validates the inputs into the form (by calling itself) how can I redirect the user to another form if the validation checks are all successful? What is the syntax for doing this?

View Replies !
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.

View Replies !
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...

View Replies !
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 :

View Replies !
[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.

View Replies !
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";}?>

View Replies !
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?

View Replies !
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?

View Replies !
Form Validation
im trying to create a php page wherein i could check the input without going to the next page and do the checking there and go back to the inout page if the user didn't enter the rght info or if he missed something. i googled and found something but it's so complicated that when i tried and tested it, it doesn't work.

View Replies !
Form Validation ?
in my project i have 10 different forms and each form has got more than 10 fields. Code:

View Replies !
Form Validation Sql
if(isset($_POST['name']))//name field is set
{
$n = $_POST['name'];
if (strlen($n) > 0 && strlen($n) < 31 && preg_match("/^[a-zA-Z'-s]+$/", $n)) //valid and sql friendly name now in $name
{
$name = trim(mysql_real_escape_string($_POST['name']));
}
else {
// $n is not valid
echo "fill your name properly.";
$fault++;
exit;
} }
if(empty($_POST['name'])) {
//name not set
echo "left the name field blank.";
$fault++;
exit; }

View Replies !
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.

View Replies !
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.

View Replies !
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 Replies !
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.

View Replies !
A Method For 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()).......

View Replies !
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?

View Replies !
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:

View Replies !
Asking For Help With Captcha And Form Validation
I'd like to use a captcha form validation on my web form, but I'm not sure if I'll be able to with my current set up.

I have a form, which when submitted, 'posts' the data to a cgi script (formmail) and then redirects the user to a thank-you page.

However, a php captcha seems to do everything within one php file - you hit submit and it reloads the php file while validating the captcha. Is there a way to get a script to validate the captcha and if valid, send the data to the cgi script and then redirect the user to the thank you page?

View Replies !
PHP Form To Email With Validation
I have form that once you have pressed the submit button will validate 3 * fields to check if they have been entered in correctly. If the have errors it will not process the form to email and instead display the errors and tell the user to amend the error fields before it can be processed.

My problem is that i have tested the validation and works to a certain standard my only PROBLEM is that if there is an error in the form it wipes the whole form clear so ultimately the user will lose everything they have entered.

I do not want this happening, much like other forms on websites i have used it still displays the form as you entered it and so you can ammend the error fields and start again making sure everything is correct and processed properly. PHP Code:

View Replies !
Form Validation With PHP/Javascript
I have a form for uploading documents and inserting the data into a mysql
db. I would like to validate the form. I have tried a couple of Javascript
form validation functions, but it appears that the data goes straight to the
processing page, rather than the javascript seeing if data is missing and
popping up an alert. I thought it may be because much of the form is
populated with data from the db (lists, etc.), but when I leave out data in
a simple textbox, it still doesn't see it. I've tried a couple of different
things, that didn't work, so I simplified and tried to address one form
element at the simplest level at a time - still no luck. Is there something
special I need to do to make the Javascript work before the PHP? Is there a
good way to do client side validation with PHP?

Here's most of the code:

function ValidateForm(upload)
{
if(IsEmpty(upload.title))
{
alert('You have not entered a title!')
form.title.focus();
return false;
}

return true;

}
</script>
<?php
NOTE: queries are here - they fill some of the list boxes

<form enctype="multipart/form-data" action="upload.php" name="upload"
id="upload" method="post" onsubmit="javascript:return ValidateForm(upload)">
<input name="uploadfile" type="hidden" value="uploadfile" />
<!--//Create the file and description inputs. -->

<table width="100%" border="0" cellspacing="5" cellpadding="0">
<snip - took out a different category listing>
<tr>
<td <fieldset>
<legend><a name="Standard" id="Standard"></a>Standard Document</legend>
<br />Complete this section <strong>only</strongif document/link is NOT
a Tool.<br /><br />
<snip - took out the generated category/subcategory lists>
</td>
</tr>
<tr>
<td><fieldset>
<legend>Document Information</legend>
<strong>Document Title</strong>:
<input name="title" id="title" type="text" size="40"
maxlength="50" />
<br />
(Required - no more than 50 characters)<br />
<br />
<strong>Description:</strong>(Required -150 characters) <br />
<textarea name="description" cols="30" rows="5"></textarea>
<br />

</fieldset></td>
<td><fieldset>
<legend>Project Data</legend>
</p>
<strong>Primary Project:</strong>
<select name="project" id="project">
<option value="value">Select a project...</option>
<?php
do {
?>
<option value="<?php echo $row_projects['projID']?>"><?php echo
$row_projects['projCode']?></option>
<?php
} while ($row_projects = mysql_fetch_assoc($projects));
$rows = mysql_num_rows($projects);
if($rows 0) {
mysql_data_seek($projects, 0);
$row_projects = mysql_fetch_assoc($projects);
}
?>
</select>
</p>
<snip- took out another listbox>
</fieldset></td>
</tr>
<tr>
<td><fieldset>
<legend>Document to Upload</legend>Upload a document from your computer.
<p><strong>File:</strong>
<input type="file" name="fileupload" id="fileupload"/>
</p></fieldset></td>
<td></td>
</tr>
</table>
<p</p>
<div align="center">
<input type="submit" name="submit" value="Submit" />
</div>
</form>
<snip>
?>

View Replies !
Serverside Form Validation
I want to validate a form serverside. And I have no idea how to check the variables for different things...

-Check how many characters are in a variable.
-Check if the variable containes a spesific character.
-Check if the variable containes any alphabetic character. This variable is puposed to only contain numbers...

View Replies !
Form Validation Query
I have a form on my website
(http://www.nprie.info/content.php?pn=12&frm=3~4). When the user
submits the form various validation checks are completed by another PHP
script. If any of these fail, the user is redirected back to the form.
The content that they submitted is retained and sent back in the URL
and picked up by another script and inserted into the fields.

My problem is with memo fields as this method of returning the data
seems to chop off anything after the first newline or carriage return.

I presume it would be better to POST this information back but how do I
do this from PHP without a SUBMIT button?

Hope all that makes sense - see the website which should clarify the
process.

p.s. the &frm=3~4 in the link simply ensures that my name appears in
the
"TO" box so if you test the script spurious messages don't go to my
colleagues.

View Replies !
Form Validation With JavaScript
I'm looking for an example of form validation by JavaScript before it's
processed by a PHP script.

View Replies !
Form Validation & Redirection
i'm making a form validation script that once it checks all the info is correct passes the visitor onto the next page. But i seem to be getting 'header already sent' problem. Here is teh general script i am using. PHP Code:

View Replies !
Form Validation (revisited)
I am 99% of the way there but now cannot get the "Reset" button to work.

I have included the whole of my code and would appreciate it if someone
could explain where I am going wrong.

<?php
$message="";
if (isset($HTTP_POST_VARS['submit']))
{

$re =
"^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.([a-z]){2,3})$" ;

if (eregi($re,$HTTP_POST_VARS['emailAddress'])){
$a = true;
$message = "<font color="green"><b>Hooray - The email address you entered
was valid!</b></font>";
}else{
$a = false;
$message = "<font color="red"><b>It Sucks! - The email address you entered
was NOT valid. Please try again!</b></font>";
}

}else{
$HTTP_POST_VARS['emailAddress']="Enter Here";
$HTTP_POST_VARS['submit']= false;
}
?>

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- Creation date: 05/02/2004 -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="author" content="Institute of Criminology" />
<meta name="generator" content="AceHTML 5 Pro" />
</head>
<body>

View Replies !
Automated Form Validation?
after coding for days on stupid form validations -
Like:
strings (min / max length), numbers(min / max value), money(min / max
value), postcodes(min / max value), telefon numbers,
email adresses and so on.

I thought it might be a better way to programm an automated, dynamic
form validation that works for all kinds of fields, shows the
necessary error messages and highlights the coresponding form fields.

Before I start to reinvent the wheel I thought I should ask you guys
if someone has done this before, or if there are some good examples of
how to do this on the web?

View Replies !
Form Validation Framework
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?

View Replies !
Form Validation Max Characters
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?

View Replies !
Some Form Validation Directions
I m trying to create a server side form validation with php. The idea is to send the user's  input to an errors.php that checks the integrity of input and then store it to a database, if i m not wrong. There are  many errors here so if someone can look at the code and point  some basic instructions  on what i m doing wrong with my functions?

My Form [hr]<form action="errors.php" method="post" name="Errors" onreset="return confirm('Do you want to reset the form?')" >



   

<h2>&nbsp;Create a User Account:<br></h2>
&nbsp;

<fieldset>
<legend>Personal Info</legend>
<table border="0">
<tr >
<th><label for="Username">*Username</label></th>

<td><input type="text" name="username" id="Username" value="" maxlength="15" class="Username" ></td>
<tr >
<th><label for="Name">*Name</label></th>

<td><input type="text" name="name" id="Name" value="" maxlength="15" class="First Name" ></td>
</tr>
<tr >
<th><label for="Surname">*Surname</label></th>

<td><input type="text" name="surname" id="Surname" value="" maxlength="20" class="Surname" ></td>
</tr>
<tr>
<th><label for="password">*Password</label></th>

<td><input type="password" name="password" id="password"   maxlength="15" class="password" ></td>
</tr>
<tr>
<th><label for="password2">*Confirm Pass.</label></th>

<td><input type="password" name="Password2" id="password2"  maxlength="15" class="password" ></td>
</tr>
</table>
</fieldset>

    <fieldset>
<legend>Contact Details</legend>
<table  border="0">
<tr>
<th><label for="email">*Email&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label></th>

<td><input type="text" name="email" id="email"  maxlength="25" class="email" ></td>
</tr>
<tr>
<th><label for="Phone">Phone&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label></th>

<td><input type="text" name="phone" id="Phone"  maxlength="10" class="phone" ></td>
</tr>
</table>
    </fieldset>


                <fieldset>
<legend>Postal Address</legend>

<table border="0">
<tr>
<th><label for="Town">*Town</label></th>

<td><input type="text" name="town" id="Town" value="" maxlength="20" class="town" ></td>
</tr>

<tr>
<th><label for="Address">*Address</label></th>

<td><input type="text" name="address" id="Address" value="" maxlength="30" class="address" ></td>
</tr>

<tr>
<th><label for="PostCode">*PostCode</label></th>

<td><input type="text" name="postCode" id="PostCode" value="" maxlength="8" class="Post Code" ></td>
</tr>


</table>

<input  id="submit" type="submit" value="Sign Up">
<input  id="reset"  type="reset"  value="Reset">

</fieldset>

</form>

And my errors.php[hr]<?php
extract($_POST);
/* Validation */
/*USername*/
function checkUsername($username)
{
  if(!preg_match("/[^a-zA-Z0-9.-ÄäÖöÜü
   ]+$/s",$username))
    return TRUE;
  else
    return FALSE;
}
/*Name*/
function checkName($name)
{
  if(!preg_match("/[^a-zA-ZÄäÖöÜü
   ]+$/s",$name))
    return TRUE;
  else
    return FALSE;
}
/*Surname*/
function checkSurname($surname)
{
  if(!preg_match("/[^a-zA-ZÄäÖöÜü
   ]+$/s",$surname))
    return TRUE;
  else
    return FALSE;
}
/*Password*/
function checkPassword($password) {
  $length = strlen ($password);
  if ($length &lt; 8) {
    return FALSE;
  }
  $unique = strlen (count_chars ($password, 3));
  $difference = $unique / $length;
  echo $difference;
  if ($difference &lt; .60) {
    return FALSE;
  }
  return preg_match ("/[A-z]+[0-9]+[A-z]+/", $password);
}
/*Email*/
function checkEmail($email) {
  $pattern = "/^[A-z0-9._-]+"
         . "@"
         . "[A-z0-9][A-z0-9-]*"
         . "(.[A-z0-9_-]+)*"
         . ".([A-z]{2,6})$/";
  return preg_match ($pattern, $email);
}
/*Phone*/
function checkPhone($phone)
{
  if(!preg_match("/[^0-9 ]+$/",$phone))
    return TRUE;
  else
    return FALSE;
}
/*Town*/
function checkTown($town)
{
  if(!preg_match("/[^a-zA-ZÄäÖöÜü
   ]+$/s",$town))
    return TRUE;
  else
    return FALSE;
}
/*Address*/
function checkAddress($address)
{
  if(!preg_match("/[^a-zA-Z0-9.-ÄäÖöÜü
   ]+$/s",$address))
    return TRUE;
  else
    return FALSE;
}
/*PostCode*/
function checkPostCode($postCode)
{
  if(!preg_match("/[^0-9]+$/ ",$postcode))
    return TRUE;
  else
    return FALSE;
}
/* Validation */

$error=0; // check up variable

/* get it checking */

if(!checkUsername($username))
{
  echo "Illegal input $username in 'Username'";
  $error++; // $error=$error+1;
}
if(!checkName($name))
{
  echo "Illegal input $name in 'Name'";
  $error++;
}
if(!checkSurname($surname))
{
  echo "Illegal input $surname in 'Surname'";
  $error++;
}
if(!checkPassword($password))
{
  echo "Illegal input $password in 'Password'";
  $error++;
}
if(!checkEmail($email))
{
  echo "Illegal input $email in 'Email'";
  $error++;
}
if(!checkPhone($phone))
{
  echo "Illegal input $phone in 'phone'";
  $error++;
}
if(!checkTown($town))
{
  echo "Illegal input $town in 'Town'";
  $error++;
}
if(!checkAddress($address))
{
  echo "Illegal input $address in 'Address'";
  $error++;
}
if(!checkPostCode($postcode))
{
  echo "Illegal input $postcode in 'PostCode'";
  $error++;
}

if($error == 0)
{
  echo
  "
  The data you entred was correct, thank you!<p>
  Your data:<br>
  Your Username: $username<br>
  Your Name: $name<br>
  Your Surname: $surname<br>
  Your Email: $email<br>
  Your Town: $town<br>
  Your Address: $address<br>
  Your phone: $phone<br>
  Your Post $postcode<br>
  ";
}else{
  echo "Number of errors: $error";
}

?>

View Replies !
Form, Checkbox Validation.
I have a list of products generated from mysql.In front of every item is a checkbox.I want only the selected items to be listed on the next page.How can I do this ? Code:

View Replies !
Form Validation And Captcha
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:

View Replies !
Form Validation Tips For All
I have read these forums a lot looking at posts and gaining a lot of information about PHP. I just want to give something back. When I begin writing code I always wonder if it's the most efficient way to write it, and if it is using proper semantics. So I purchased the PHP Cookbook http://www.oreilly.com/catalog/phpckbk/ and I wanted to share some of the code with you. All these code snippets have to do with form validation and processing because that is one of the most popular subjects of PHP. I don't want to rip off the book so I will post the code but try and write my own descriptions. Code:

View Replies !
Edit Form Validation
i have an edit form which as a validation code to check if the new parent category/subcategory is not yet existing in the database. apparently only my parent validation code is working, but my validation code for the subcategory is not working. Code:

View Replies !
Form Field Validation
When validating user input I check it's not empty and then run 'mysql_real_escape_string($s)', I was then going to make sure that it is only alphanumeric, but I wanted to allow certain other characters as well. Realising this must be done before the mysql escape check, what characters should be blocked because they are dangerous, I can only really think of quotes and $. The real escape check should handle the quotes issue, so is the $ an issue or not? 

View Replies !
Form Validation Using Functions .
let's say I have a mutli-page form. I use functions to validate each form field individually. So I have:

<?php
require_once(form_check_functions.inc)

foreach ($_REQUEST as $Key => $Value){

($Key === "surname")? $surname = check_surname($_REQUEST['surname']) : ''
($Key === "name")? $name = check_name($_REQUEST['name']) : ''

...

in the functions I assign the value of the request to a session if it validates (to carry it across the form pages) and unset the session if it doesn't validate (in case it's ok before and then changed). If all the form field have a corresponding session my form was correctly field so I move on tho the next step.

View Replies !
Form Validation :: Where To Start?
I'm looking to get a fairly simple form validated using php, but I dont know where I should start as I'm new to it. Dont really want to do this client side, hence posting here. I have a few text fields and one checkbox on my yourinfo.php page, which I send to a SQL db upon submission of the form, and then autoforward into the next page. I would like to be able to validate the content of these fields (ie email address is checked for validity) before going into the db.

View Replies !
Form Validation Code
I've seen many form validation codes, where users have to enter a unique code in order to validate the form. I've seen this code on sites where you can use their code but you can't view the code, so you have to link to that site as you've used their code.

Does anyone have any simple code that does this. I just need one text box and a unique code next to it so the form can be validated.

View Replies !
Form Validation :: Easy Way Of Doing?
I wanted an easy way to validate my forms in php. I didn't want to write tons of if loops and stuff each page since I have a ton of forms and stuff on the site I am making. So I decided to make a class based approach.

What I am really looking for is just feedback on the method that I've used. See if there was a better way to do things. Right now it registers a rule into an array and then the check function goes through all the rules to see if the form is valid or not, and then the errors are output if the validation fails. Code:

View Replies !
Form Validation And SQL Injection
I've been searching around for a while to try to add php validation to my register and login forms, after reading a, quite shocking, article about SQL injection, as it seems so easy! I have found the code I need in several places, but I don't understand that, and so wouldn't be able to add my own magic touch.

View Replies !
PHP Form Validation System
Is there any good book for PHP Form Validation System? I have read great article from Mike Weiner and if somebody knows where to find more about this?

View Replies !
Form Validation Script
Where can I find an online PHP form validator script library to use? I
have tried hacking the one here at work for weeks now and it's getting
more and more impossible to customize, especially now with form
elements that turn out to be arrays that have to be compared with one
another!

I have one form element, languages, a checkbox group. Beside each
checkbox is a dropdown, proficiency (which will become proficiency[]
alongside languages[]). The crux of the matter is that I have to
compare a checked language with the selected proficiency, the
proficiency dropdown beside the checked language must be selected;
furthermore, at least one language must be checked, up to 4. Code:

View Replies !
Address Form Validation
i'm after some information on validating address's from everywhere, probably postcode and telephone numbers are most important. Could someone show me a list of how each country formats theirs, even better for an example with php n regex.

I've done some googling, but it left me dangling with many pay services which look up for you, but i don't really need that level so...

View Replies !

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