Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsOtherProgramming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old May 29th, 2008, 02:37 PM
sudhakararaog sudhakararaog is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2007
Posts: 11 sudhakararaog User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 4 m 30 sec
Reputation Power: 0
PHP - Form validation in php

i need to validate a field in a form where a user enters a reference number this can be

letters, numbers and special characters also so i have not written any special preg match as

the username is a combination. the only check i am doing is if there are any white spaces

and if a user simple presses the space bar and does not enter value i display a message to

enter the reference number and even if there are white spaces followed by the reference

number i have used trim method. i have checked in the database even if there are white

spaces followed by reference number due to trim() method the data in the table is being

inserted whithout those white spaces.

following is the code i am presently using

$referencenumber = trim($_POST["referencenumber"]);

if(strlen($referencenumber) == 0)
{
$error.="<li>Reference number cannot be blank </li> <br />";
}


this code works perfectly fine and does what it is supposed to, however i am using

techniques to avoid sql injection. following is the technique i have used

if(get_magic_quotes_gpc())
{
$username = stripslashes($_POST["username"]);
}

else
{
$username = $_POST["username"];
}


due to this even if i use

if(get_magic_quotes_gpc())
{
$lodgementnumber = stripslashes($_POST["lodgementnumber"]);
}

else
{
$lodgementnumber = trim($_POST["lodgementnumber"]);
}

if(strlen($lodgementnumber) == 0)
{
$error.="reference number cannot be blank;
}

the validation is not doing what it does in the code i mentioned at the begining.

i need to use techniques to avoid sql injection and i also need the validation to work.

how can i fix this.

please advice.

thanks.

Reply With Quote
Reply

Viewing: ASP Free ForumsOtherProgramming Help > PHP - Form validation in php


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT