veerumits
Oct 21 2008, 11:55 AM
| | I dont want to use javascript as a validation form i want to use Regular expression in PHP for Login or other page. please any one have a best code for validation in PHP. as i thinks that web site Validation on server site is faster then client site validation. Most welcome. |
Comment/Reply (w/o sign-up)
Lyon2
Oct 21 2008, 08:08 PM
I do not know the php code for web form validation in my head, i could find it in my computer when i get home, but i can tel lyou now that, with my experience, javascript is better for the validation of web forms, and besides, most of web designers use javascript to validate their web forms because it is very simple, allthough the php code e could be simple too, i do not know it for now, sorry, perhaps later.
Comment/Reply (w/o sign-up)
galexcd
Oct 21 2008, 10:20 PM
QUOTE(veerumits @ Oct 21 2008, 04:55 AM)  I dont want to use javascript as a validation form i want to use Regular expression in PHP for Login or other page. please any one have a best code for validation in PHP. as i thinks that web site Validation on server site is faster then client site validation. Most welcome. Using javascript to validate user input is nice because it doesn't require the user to have to reload the page, the browser does all the work, however the problem with solely using javascript is that it could easily be modified to allow users to bypass whatever validation javascript is running. You could use ajax to have javascript validate the data with the server but that is even more pointless. What I would personally recommend if you wanted to make your website both user-friendly and secure, have both javascript and php check validation of the input. Javascript will easily alert users if the input they entered does not match what the website expects, and users who either disable javascript or attempt to get around this will have a php error message returning the same error javascript returned. As for using regular expressions, we can't exactly give you any code unless you tell us what exactly you want to allow or deny in the string.
Comment/Reply (w/o sign-up)
xpress
Oct 22 2008, 06:00 PM
QUOTE(galexcd @ Oct 22 2008, 03:50 AM)  Using javascript to validate user input is nice because it doesn't require the user to have to reload the page,
As for using regular expressions, we can't exactly give you any code unless you tell us what exactly you want to allow or deny in the string. Yes. I agree with galexcd. Javascript for validating is the best and fastest option. Because all the validation will be done on clients browser. So it will be obviously the fastest. And also user friendly. Why? because the user correct all his mistakes at one time before submitting the page to server. If all the validation will be done at the server side, user feels it annoying because he need to submit the page many times to correct all his mistakes. It is a time taking process for the user and is very slow. So validating it on client side is best. And also it saves some process haedache of server. But of course, server side validation should also be implemented. As galexcd said, it is very easy to change everything which is on client side and bypass any restrictions they have. This can lead to some security issues. So, server side validation is also needed. Since, client side validation is already done, the data is valid most of the time, and no need to repeat the process again.... And about regular expressions, how can we give if we don't know what you and your code need? Give us complete details and we'll help you.
Comment/Reply (w/o sign-up)
shadowx
Oct 22 2008, 07:40 PM
I agree with everything said already. You should use a Javascript validation to check every key press and see if that keypress is any of the following: " ' : , . @ | $ £ % ^ & * ( ) and so on..... Then in the PHP validation use a regular expression of the format: /w that should check for all alpha-numeric characters (a-z 0-9) you can also add a character limit with something like {5,20} (which is: {min,max} ) Im not very good with regex otherwise i would write the whole thing for you, but it gives you a starting block
Comment/Reply (w/o sign-up)
dragonfang00
Nov 7 2008, 03:04 AM
as for galexcd said, using javascript for validation is more appropriate than php.. client-base is much better and it is user friendly than php.. but you should also have php validation after.. you can search for codes in google..
Comment/Reply (w/o sign-up)
Nabb
Nov 7 2008, 06:25 AM
QUOTE(shadowx @ Oct 23 2008, 06:40 AM)  I agree with everything said already. You should use a Javascript validation to check every key press and see if that keypress is any of the following: " ' : , . @ | $ £ % ^ & * ( ) and so on.....
Then in the PHP validation use a regular expression of the format: /w that should check for all alpha-numeric characters (a-z 0-9) you can also add a character limit with something like {5,20} (which is: {min,max} )
Im not very good with regex otherwise i would write the whole thing for you, but it gives you a starting block Try this one: if(ctype_alnum($_REQUEST["user"])){ [..] } There's probably other similar functions except I just opened a random file and looked what was inside and that's all I found! Regular expressions are much slower than this type of check, so it's better to use something like this. Or so I've heard.
Comment/Reply (w/o sign-up)
(G)Generic Guy In Trenchcoat
Feb 26 2009, 07:20 PM
I disagree with most of you
Php Code For Login Form With Validation In Php
Javascript is not better for form validations. It is ok if you trust your users but as a matter of principal one should assume that every user has malicious intent. There are many ways to get around javascript validations. The easiest being as simple as turning javascripting off. If you work around that by using javascript to create the forms then a user could just make thier own forms.
What really matters is not the users process of forming their input to meet the requirments for sending data to the server. What really matters is the actual data that is being processed by the server. If you don't validate and secure the actual process that is handling the information then you might as well not do any validation at all.
You must secure that chokepoint. If you control the entrance then nobody can get in. If you go wander up and down the sidewalk and hassling people on their way to your house they may just hop over the fence beside your house walk in the front door while you are stomping about the street.
Use php to secure your input.
-reply by Generic Guy In Trenchcoat
Comment/Reply (w/o sign-up)
Similar Topics
Keywords : php, code, login, form, validation, php
- Create Table - Mysql Code - Help
(1)
Php Source Code Unveiled In Browser?
is that possible? (7) I am quite new to PHP and this concern came to my mind after playing around a bit with it... When
PHP is not correctly configured on the web server the source code of a php file we try to access
through a browser will be shown instead of the result of the code itself. This will normally not
happen when PHP is working properly, but I was just wondering if it could still be possible to see
that code if a user wanted to or if something on the server failed. This would for example expose
sensitive information like mysql passwords and so on... Is anything like that possib....
Malicious Code Injection
(3) Hi everyone! This is my first post, so be kind! Basically, I'm trying to get a free host
together so am writing some posts. Here's a little summin' summin' about malicious code
injection with PHP applications. Basically, this security exploit is one of the oldest tricks in
the books and all comes down to the fact that PHP allows execution of both local and remote scripts
with the SAME function... dur. Anyway, this is how it works. Image you've just employed a young
go getter, straight outta uni, who has found becoming a Jack of all trades a sinch. Y....
Php And Mysql Programming
anyone knows a code for mysql and php (2) hi everyone! I am making a program using php and mysql...I am a noob on this so i need your help
guys...I want to make a simple program that will some values and then store them on a database and
then retrieve them...uhmm let me give an example out put of what i need. This is the example say..:
Enter First Name: Enter Last Name:
Enter Age: Enter Address: ..those are the
data needed for input values...my question now is how can I make a database whi....
Php Code Needed Iii
(10) Hello, everyone. I need your help again! Who might create the PHP code, the picture is above
this text. Basically, I want when the user fill in all the information in this form, it
automatically was sent to my email. And, then, the dialog box appears or on the same window, it was
said that your request has been sent. Moreover, if the user did not fill the entire information,
the dialog box appears stating that you did not fill some field. Thanks, for help. You always do
that.....
Php Code?
Mathematical Applications (12) Hello, everyone. The help is needed again. How can I make calculator in PHP language? That will act
like that a user just type in the fields known values, then click the button, and it's going to
be solved automatically. In other words, have can I write a formula in PHP, how to plug it inside
that language. For example, the formula to find a peremeter of square is: P=4a. So, a user
just can write the known value which is peremeter itself and it will find the side of a square; and
vice versa. If you can write many things how to do such formulas, such as comp....
Php Code Needed
Working Together? (5) Hello, everyone. I need your help again. This forum is quite good for it. Well, I need create a
registration form for my web-site using PHP and SQL. The information it should contain: 1) User
Name 2) First Name 3) Last Name 4) Password 5) e-mail Address 6) Security Image: that images helps
to protect a random registration, for instance, 56+2=where user have to type an answer in order to
finish registration. That's all for today. Anymore things, I will post another post over here.
....
Php Code
Needed?! (15) Well, I am a novice in PHP programming, so there is a script which I wanna get: 1. You go the
web-site 2. On the main screen, there is a some kind of field windows, the one you get used to type
in, when you go to google, for instance. 3. He or she types her email address and it's going to
be saved in my SQL database. 4. That's it. Help me if you can.....
One Login Account At One Time
(3) When we login, we got a session. But at the same time when we still login, another one could login
at our account. So, can we restrict only one user could login at one account? So if another wants
to log into the same account, he must wait until the one logs out. Thanks in advance.....
Use Rss In Php Code
(3) so, how can I make RSS reader on my website? thanks in advance....
Will This Code Work
php linking script ?p= (5) hi i'm not that great at php so i'm not to sure if this will work or not. but what i want to
do is be able to use ?p=staff or what ever page name, with out the php extion, and i would like to
no if this simple script i made would work. the code is: CODE $p = $_GET ; if ( !empty($p) &&
file_exists('./' . $p . '.php') && stristr( $p, '.' ) == False ) { // pages
= directory where you store your pages $file = './' . $p . '.php'; } else { //
1.php = defult page $file = './index.php'; } include $file; ?> ....
Php Email Validation
A PHP data validation class with many functions (1) I've been reading through my old php book (PHP 4.1) and came across this data validation class.
It can check a number of things ranging from telephone numbers , credit card number formats, email
address and some others. I checked out some of the methods although I didnt expect it to work 100%
because I've found source code errors thoughout the book and CD. I tested out a few of the
methods to check and some of them did return expected results but some didnt either so the data
validation class was not perfect and it didnt really bother me. The cool thing I found....
I Need Some Proof Reading For My Code Please! [resolved]
(7) Well... everything is fine except the Content Select section (refer to the in-code headings)...
thats where it says the error is... could anyone find out why it wont work when I click one of my
links? http://2kart.trap17.com/progress.php for an example of what happens...
//----------------- //portfolio paths //----------------- $portfolio = "/portfolio"; $lay =
"/images"; //------------------ //navigation //------------------ $link = · Home html; $link
= · Portfolio html; $link = · Programming html; $link = · Graphics html; $link
= ....
Html Code Tester. Online Script
(15) Yes, yes. I have another script that I have written and I am distributing. I am not entirely sure if
this works. I have not tested it yet, but I will later and post back with a demo and fix it up.
Current script: CODE //Save this as something like htmltest.php function CheckForm() {
$html_unsafe=$_POST ; //Gives us our user input $html_safe=str_replace(" //Starts security measures
$html_safe=str_replace("?>"," ",$html_safe); //User input now secure server side //Still security
issues client side echo $html_safe; //echos our statement } //End function //Main script....
Awesome Source Code Viewer Script
(7) Hello! I have just came up with a sweet script to show the source code of any website and it only
requires one file. This is the basis of the script and can be customized with CSS and other things
and can be instituted as a public resource. Well I will provide the code and a step-by-step tutorial
on each of its parts. This code has been tested by me. Enjoy! CODE //This little tag starts
our php script and is easily the most important part of the script. //We will start our base script
here. //You can change some of the styles used here to your desired color. if (....
Html Site With Login
Is it possible? (2) Hello. I“m building my own site and I need some help... Is it possible to use a login sistem in php
and mysql database in a html site? ....
Login System
(6) i am designing a site for my alliance for the game Dark Throne. and i want some content to be
availabe to members of the alliance only, and other content to be available to people with a certain
rank within the alliance. i know this should be somewhat simple, but i am not that sure how to do
it. my idea for the website is just have basic info about the alliance available to everyone, then
news about the alliance and member lists and other things like that available to every alliance
member, then things such as the strike team, diplomat team, and special areas like that,....
Username Validation With Php
(1) A simple method of validation. This is good if you dont want spaces between caracters: form.php
CODE User name: vali.php CODE $user =$_POST ;
$cuser=0; for($i=0; $i { if ($user ==" ") { $cuser=1; } } if($cuser==1) { echo
"The user name have spaces"; } else { echo "The user name is correct"; } ?> Remember, all
code must be placed in CODE BB tags. Thank you. ....
Php Login Script
(1) I'm looking for a good php login script. I would like one where it pops up. like http-auth. but
with out the data base. I would also like for it to have a log out fuction.....
Is This A Good Script?
A login script (9) Okay, I am trying to password one page of my website. I need confirmation if this is a safe code or
not. The whole code is on the page I'm protecting. CODE // Define your username and
password $username = "THE_USERNAME"; $password = "THE_PASSWORD"; if ($_POST != $username || $_POST
!= $password) { ?> Login "> Username Password }
else { ?> The stuff being protected here.... Is this a safe script, or could someone
possibly discover the username and password?....
Display The Current Date/time
With a simple PHP code (4) Use this code to display the current date and time. CODE $date = date('l dS \of F Y
h:i:s A'); echo "$date"; ?> "l" would display the current day of the week such as
Sunday. d displays the day of the month... such as 1 and S adds the appropriate suffix(st). /of
simply displays the word "of". F displays the current month with no abbreviations while Y displays
the four digit year(2007). "h" displays the current hour with leading zeros if necessary(Ex. 06 for
6 o'clock). "i" displays the minute of the hour with leading zeros if necessary. ....
Wap Source Code Viewer
Mobile/wap source code viewer page (4) This is a source code viewer that will workl on wap/mobile sites but you can easily convert it to
work on web im sure ;-) CODE header("Content-Type: text/vnd.wap.wml"); echo '
'; print " "; if ($url == "") { echo " Enter url: »View source code "; }
if ($url == "$url") { $udata=@file_get_contents("$url"); $udata = str_replace("$","$$",$udata);
$udata = str_replace("&","&",$udata); $udata = str_replace("'","'",$udata); $udata =
str_replace(" $udata = str_replace(">",">",$udata); $udata = str_replace("\"....
Automatic Login Using Curl
(11) If you'are lazy people like me. This script may help u. This script is to automated our login to
some site. You must have cURL installed to use this script. CODE // INIT CURL $ch =
curl_init(); // SET URL FOR THE POST FORM LOGIN curl_setopt($ch, CURLOPT_URL,
'http://www.external-site.com/Members/Login.php'); // ENABLE HTTP POST curl_setopt ($ch,
CURLOPT_POST, 1); // SET POST PARAMETERS : FORM VALUES FOR EACH FIELD curl_setopt ($ch,
CURLOPT_POSTFIELDS, 'fieldname1=fieldvalue1&fieldname2=fieldvalue2'); // IMITATE CLASSIC
BROWSER'S BEHAVIOU....
Requesting Auto Generating Id Tag In Php Code
Php Coding (3) Hello...I'm designing a website in PHP where ppl can submit their links for "cool sites".
Anyway, when somebody submit's a link to a website for example "http://www.google.com" it
creates an id such as "index.php?id=1134411593". I dont want the links to be converted into
id's. I want it to remain as "http://www.google.com". I have the following coding on
( echo " ). I'm a novice. Please Help!!!! Thanks... Plus I
also want to add the date on when the link was submitted. Please follow our forum rule by making....
Dynamic Image / Signature Generator
a simple code to change text on an image (12) In search of dynamically changing quote, saying or all other types of text on an image I came across
a code that I have modified to fit my initial usage. This procedure requires two files and short
knowledge of PHP. If you are familiar with Trap17's sig rotation code you will understand this
procedure very fast. Code 1: dynamic_sig.php (you can rename this to index.php and you'll see
at the end why) Code 2: a simple text file named anything (I will call it name.txt ) Code 1
CODE header("Content-type: image/png"); $image = imagecreatefrompng("../i....
Adapting Html Code Embed To Work On Phpnuke
Help With This Html Code Pls (7) QUOTE how can get this html code to work on my phpnuke site? what tags would i
have to enable in the $Allowable HTML part of my config.php file?? Edited topic title. Moved to
Programming. ....
Change Permission With Php Code
code to change files' and folders' permissions? (3) As everyone know, there two ways (that I can think of) to change files' and directories'
permissions. One is to change it in your cPanel's Disk Manager and the other is with an FTP
client that supports chmod. Well, I'm doing something for my site that requires files to have
full permissions (Execute, Write, and Read on all three groups). At first, I thought that if I made
the directory 777, then every file created in that directory will be 777 as well. I'm wrong. An
alternative to doing this is to change each file permission myself, but that would be....
Get Filename Of Referring Url
php code to get filename of referring URL (9) Hey /smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /> I want to know how
to get the filename of the referring URL. Look at the following example: Page A which has a URL of
http://blah.trap17.com/blah/blah1.php redirects the user to Page B which has a URL of
http://blah.trap17.com/blah/blah2.php . Is there a PHP code that I can put on blah2.php that will
output blah1.php? I tried _SERVER ; (please note the code may not exactly be correct as I do not
remember the code /laugh.gif' border='0' style='vertical-align:middle' alt='laugh.gif' />....
Php Clock
source Code (8) Hi Every one i find this code its very easy simple php clock i think you can use it /blink.gif'
border='0' style='vertical-align:middle' alt='blink.gif' /> CODE // Binary Clock // script
copyright© 2002 Andreas Tscharnuter // questions? contact: psychodad@psychodad.at ||
http://www.psychodad.at/clock/ // free to use, copy and modify but leave comments untouched;) //
just include this file where your binary clock should appear // version 1.2 03 September 2003 //
below you can change different settings // and remember to drink m000re milk! $size = "40"; ....
How do you test your php code
(97) We know that php is a server side scripting language. So we will need a server with the php parser
to parse/test our code. How are you doing that. Do you upload it to a server for testing or did you
instal php and the server (apache) on your computer (localhost)....
Looking for php, code, login, form, validation, php
|
Searching Video's for php, code, login, form, validation, php
See Also,
|
advertisement
|
|