Page: 1, 2  Next

Useful script to validate forms with PHP
techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Posts: 4127
Location: East Coast, West Coast? I know it's one of them.
Reply Quote
Very interesting method to do form validation at evolt.org

:: Quote ::
You want a function that displays a form element. The element should get a meaningful initial value that does not get submitted in the end.

As an extra for Javascript-enabled browsers, text elements should get emptied when you click on them if they contain the initial value.

If the element is a mandatory field and is empty, or contains the initial value, it should get highlighted. If the form has to be re-displayed due to some other element missing, the element should display the last submitted value.

The function should do that for text boxes, text areas, checkboxes, radio buttons, and select boxes. Also, it should not change any additional elements and attributes like accesskey, taborder, classes or colgroups.

Back to top
try this
mike
Status: Contributor
Joined: 08 Oct 2004
Posts: 71
Reply Quote
the new thing is client side validation using xmlhttprequest. I havent quuite messed around with it as much as i would like yet but it looks very promising...

via kottke

for asp specifically

a more general ajax approach
Back to top
jeffd
Status: Assistant
Joined: 04 Oct 2003
Posts: 594
Reply Quote
Too bad the xmlhttprequest is a proprietary ms method, or at least that's what it looked like, just skimmed through those articles.

In general I don't bother using any proprietary methods, it's too hard to learn stuff as it is, too much, so as soon as I realize something is actually proprietary I just make a mental notet that it exists, then go onto non-proprietary, and ideally simple, solutions.
Back to top
mike
Status: Contributor
Joined: 08 Oct 2004
Posts: 71
Reply Quote
I still have a lot more reading to do about it, but something tells me it might not be. It seems to be the new big thing, and alot of the web standards crowd seems to be raving about it. It definately has a lot of potential. When I learn more about it, I'll come back and make my final judgement.

As an aside, I used to be a very anti-microsoft/asp type of person, but I've been doing a ton of reading lately about windows technology and .NET framework and for very large scale operations I'm beginning to believe that it's in some cases a much better solution than php/apache/mySQL.

I definately agree though that for most cases and the average webmaster that apache/php/mySQL way is a much better way to go and has a much less steep learning curve.
Back to top
jeffd
Status: Assistant
Joined: 04 Oct 2003
Posts: 594
Reply Quote
:: Quote ::
I used to be a very anti-microsoft/asp type of person, but I've been doing a ton of reading lately about windows technology and .NET framework and for very large scale operations I'm beginning to believe that it's in some cases a much better solution than php/apache/mySQL.

Programming and programming tools
That's not actually a valid comparison, it's not so much MS .net or php/apache, for serious production there are a bunch of serious options out there, for example, for db's, postgre is considered I think a bit more serious than mysql, and a few major corporate level dbs have just been opensourced, ingres is one I think, there's a few more, pretty major products.

In terms of programming languages, php is just one of the tools, google for example was first written in python, then they moved a bunch of their stuff to compiled c or c++ modules, but they still use python extensively. Python is sort of the programmer's dream language, it was made to make programming easy, and let the computer worry about the hard stuff, sort of the same philosophy behind things like lisp/scheme too.

There's also a bunch of different apache type products, for increasingly complex applications.

PHP/Mysql/Apache is just the combination we tend to be familiar with, it's sort of like html/css/javascript, but it doesn't end there, just like html moves into xml, css moves into xslt, and php can drift towards perl, python, c, whatever is needed.

How and why Microsoft works the way it does
I'm very familiar with MS, both from knowing people there, hanging out there, it works in a certain way, and that way is very consistent:

MS makes what its corporate partners need, it's the market they take care of the most, that's major corporate partners. The largest corporations have onsite ms employees, that goes both ways.

What corporations want is to drop the required skill levels to accompllsh any task. This is the key to understanding MS's corporate computing policy. This is why hackers don't like working with MS stuff, by the way, it's generic, bland, doesn't offer you nearly the flexibility or control, but drones can be put into place to accomplish certain tasks with a reasonable expectation of the thing somewhat working. Forget craft, skill, pride in work, this is just bland get the job done so I can report it done and get promoted and not have to deal with this stuff anymore type work.

I took ASP and MCSE courses, did very well in them, but I have felt only one thing about the time I spent learning MS products: regret.

Improving over time, not MS, your skills
The time I've spent on windows, if I had spent it on Unix based systems, would have given me increasingly deep understanding of these systems, with skill growing and deepening. This does not happen with MS systems, what you learn with them is simple: how to use them, how to make the tools MS gave you work to do the job. You're always following MS, which in turn is always moving in close relation to its corporate partners, whose ultimate dream is to put you out of a job, period.

Some reasons I don't like MS products
For me it's not really an option, though I studied asp, and did extremely well at it, and could easily have moved into that part of the market, there was the little problem that I didn't like it, I didn't know why until I found PHP, which explained it all to me the first site I put live using PHP. MS products just bug me, I can always feel the serious compromises that have been made in any programming decisions, those compromises are for two main areas:

1. To maximize MS's profits, which currently enjoy roughly a 30% level, that's because they're having good luck avoiding prosecution for their monopoly practices.

2. To make what the corporations want, plug and play, low skill stuff.

Step 2 is a fantasy though, one very good MS programming teacher I had told us stories about being involved with multi hundred thousand dollar jobs, where the architecture for the projects was evolved using key VB components. Once the project hit the point in development where those components could be implemented, there was a show stopper bug in VB with that component. They called MS, who said, yes, we know all about that bug, it's been around a while.

I'm not kidding. It wasn't patched, it wasn't fixed, they just left it there. There's a reason for this though. If you were working for say Siemens corporation, and you called them on a bug, they would fix it. If you're smaller, they won't. That's a huge difference in the open source model.

I've personally come across seriously amazing bugs working with MS products for the last 5 years, simply amazing ones, like where if you export an excel file with the first field named, lower case, id, into access, the import fails, that's an ms bug, between two ms applications, written by ms. That's not funny, and is typical, and is why I don't like working with their stuff, they simply don't care in the way that people who do this work for reasons that go beyond money do.

Personally, I don't plan on spending time chasing MS's latest idea around, any time I spend learning is going to be on stuff that doesn't depend on some huge company that could care less about my needs.

Some of the real rewards of working with Open Source
There's an added bonus for me too: every single thing almost I learn with open source stuff deepens my understanding of the underlying systems, whether in networking, OS, programming, whatever. All I learn with MS products is how to use them, period. I've had office admins tell me for example that they know how to use a database, I always laugh, and ask them how their sql is, which draws a confused stare. I studied Access too, don't ask why, it was a bad idea, same result: total waste of learning time. All time I spend on mysql for example radically improves my understanding of the actual db mechanism, since it's not hidden from me.

And so on. I'll have to read up on xmlhttprequest though, one of the links you pointed to said it was an IE 5x only thing, maybe 6.

Previously
By the way, I used to be a very pro microsoft person, but doing constant work with their stuff for years has made me dislike it more and more, plus the above fact that the more real computing stuff I learn, the more time I realize I've wasted with MS products. And I also realize just how suckered in I was. This confusion is a key component to MS growing by the way, they need people to think that way, or they would be just another player in the software market, which is what they should be.
Back to top
mike
Status: Contributor
Joined: 08 Oct 2004
Posts: 71
Reply Quote
:: Quote ::
And so on. I'll have to read up on xmlhttprequest though, one of the links you pointed to said it was an IE 5x only thing, maybe 6.


It most certainly works in firefox, and I'm pretty sure it works in opera as well. Some things that can be created with AJAX though, will only work with msie. It just depends what you try to do with it. Perhaps you're thinking of the asp link. the form assembly link I think is a very nifty client side validation method. You can check out the many examples given: www.formassembly.com/form-library.php

It basically just uses DOM Javascript and CSS. When you get some more time take a look.

Perhaps the lack of depth in MS products is somewhat of an appeal to me, as I'm far from what I would call a programmer. What's most odd though is that for something that's supposed to be easy, I always have a hell of a time getting any asp stuff to work. While on the other hand php is a piece of cake, at least to hack up some simple things.

After thinking about this more, I think it would probably be most beneficial for me to learn to work with different database systems rather than to learn to work with asp/.NET. Most windows servers have php running on them anyhow. If I understand correctly, it's mySQL that is the limiting factor.

As for the reason many big corporation go with MS products, the reason to me seems clear as day. They do it for the support. That's what I continue to see as a huge thing that is and will possibly continue to hold back open source.
Back to top
jeffd
Status: Assistant
Joined: 04 Oct 2003
Posts: 594
Reply Quote
:: Quote ::
What's most odd though is that for something that's supposed to be easy, I always have a hell of a time getting any asp stuff to work. While on the other hand php is a piece of cake, at least to hack up some simple things.

Having just worked on a revolting ASP script, there were I think one or two things that were easier in ASP, the rest is extremely annoying. Lack of real commenting is by far and away the most annoying thing, not being able to comment out blocks of code with a single click is highly aggravating, I don't know if that's been fixed in asp.net or not, but it's totally absurd, that is:

:: Code ::
'some notes, then comment out the block
'if (some statement)
'do something
'do something else
'endif

// compared to real comments:
/*
//some notes
if (some statement)
{
do something;
do something else;
}
*/

That decision could NEVER have been made if user input was part of the programming development process. MS didn't allow real comments for I believe one and only one reason: they want to pretend they are different, and don't want to admit that programming is programming in any larger sense.

:: Quote ::
Perhaps the lack of depth in MS products is somewhat of an appeal to me, as I'm far from what I would call a programmer.

Exactly correct, that's precisely who MS is creating their systems for. It's a fantasy, as my above example shows, things like programming automation just are too restricting, having MS make decisions for you gets very annoying over time, since many of those decisions have nothing to do with what you actually need.

:: Quote ::
After thinking about this more, I think it would probably be most beneficial for me to learn to work with different database systems rather than to learn to work with asp/.NET

Problem there is that db work is hard, the more advanced it gets, the more serious the errors you can make get, and the harder to fix. Learning which system is the best choice is a good thing to know, but trying to implement that choice without knowing how to do the sql, db architecture, and so on, except for very simple systems, can be catastrophic, especially for a large enterprise.

On the bright side, mysql is good enough for most apps that an average developer will deal with, if you compare Access and MySql, mysql is radically superior, in every way.

:: Quote ::
As for the reason many big corporation go with MS products, the reason to me seems clear as day. They do it for the support.

And only big corporations get that support, by the way, the rest have to struggle along, with no support at all, which makes the whole support thing a gigantic red herring. I worked at a place where we had about 250+ windows machines, and I guarantee you, when we had problems, we NEVER called MS for support. Most of the network admin's time was consumed with trying to make MS systems work, making the network work. That's why they were switching over more and more to Linux/Redhat servers, Redhat's support is better than MS support, their latest server packages offer the same 5 year support option as MS claims to offer, but it's real support.

We debugged windows, we fixed windows, we removed malware from windows, we set up and tried to get working windows and windows servers, there were a few. Support for these issues, especially updating installations, comes down to MS telling you to buy their SMS server to handle updates. Claimed support is non-existent, in other words. Unless you are very big. Then there is real support.

But this is fairly unrelated to MS programming, .net etc, where support is meaningless, you have the run time environment installed, it comes down to the programmers and their skills, the system architects and their skills, then the final prayer that you won't be the one to find that killer bug in .net that stops the project dead. I guarantee you, the example I gave above is accurate, there is no support, MS doesn't pay you your development and debugging time when their stuff has bugs.
Back to top
mike
Status: Contributor
Joined: 08 Oct 2004
Posts: 71
Reply Quote
as a side not, do you know one would go about setting an IIS to run htm/html files through the php parser?

I know for apache it would go something like:
:: Code ::

AddType application/x-httpd-php .htm .html
php_value include_path ".:/usr/www/users/whatever/includes"


is it the same on an IIS server?
Back to top
mike
Status: Contributor
Joined: 08 Oct 2004
Posts: 71
Reply Quote
:: jeffd wrote ::

Exactly correct, that's precisely who MS is creating their systems for. It's a fantasy, as my above example shows, things like programming automation just are too restricting, having MS make decisions for you gets very annoying over time, since many of those decisions have nothing to do with what you actually need.


Actually the one thing I've heard as a plus for the .net is that you can integrate a wide variety of programming languages from perl to python to C.

:: Quote ::
Problem there is that db work is hard, the more advanced it gets, the more serious the errors you can make get, and the harder to fix. Learning which system is the best choice is a good thing to know, but trying to implement that choice without knowing how to do the sql, db architecture, and so on, except for very simple systems, can be catastrophic, especially for a large enterprise.

On the bright side, mysql is good enough for most apps that an average developer will deal with, if you compare Access and MySql, mysql is radically superior, in every way.


Oh, I agree it's very difficult to learn, but that doesn't mean it would not be worth attempting to learn. It would come to be an invaluable skill in the long run. Are most database based on SQL? or is oracle and the rest all their own animal? Which do you think would be the most powerful? the reason is that if I ever get the opportunity to do some work for larger companies, I would love to be able to offer them alot more on the programming end of things.

:: Quote ::
And only big corporations get that support, by the way, the rest have to struggle along, with no support at all, which makes the whole support thing a gigantic red herring. I worked at a place where we had about 250+ windows machines, and I guarantee you, when we had problems, we NEVER called MS for support. Most of the network admin's time was consumed with trying to make MS systems work, making the network work. That's why they were switching over more and more to Linux/Redhat servers, Redhat's support is better than MS support, their latest server packages offer the same 5 year support option as MS claims to offer, but it's real support.

We debugged windows, we fixed windows, we removed malware from windows, we set up and tried to get working windows and windows servers, there were a few. Support for these issues, especially updating installations, comes down to MS telling you to buy their SMS server to handle updates. Claimed support is non-existent, in other words. Unless you are very big. Then there is real support.


Oh, I absolutely agree.

:: Quote ::
But this is fairly unrelated to MS programming, .net etc, where support is meaningless, you have the run time environment installed, it comes down to the programmers and their skills, the system architects and their skills, then the final prayer that you won't be the one to find that killer bug in .net that stops the project dead. I guarantee you, the example I gave above is accurate, there is no support, MS doesn't pay you your development and debugging time when their stuff has bugs.


Very true. One arguement I read in favor or .asp/.NET was similar to just that. The guy argued that most people confuse .asp with visual basic. The problem is, he argued, that most people are not skilled enough to take advantage of the technology and use it to its full potential.
Back to top
jeffd
Status: Assistant
Joined: 04 Oct 2003
Posts: 594
Reply Quote
This site has the basic information, note the authors by the way, Rasmus Lerdorf, guy who makes PHP is one of them.

:: Quote ::
For the first and most common form, you need three things: PHP itself, a web server and a web browser. You probably already have a web browser, and depending on your operating system setup, you may also have a web server (eg. Apache on Linux or IIS on Windows). You may also rent webspace at a company. This way, you don't need to set up anything on your own, only write your PHP scripts, upload it to the server you rent, and see the results in your browser.

While setting up the server and PHP on your own, you have two choices for the method of connecting PHP to the server. For many servers PHP has a direct module interface (also called SAPI). These servers include Apache, Microsoft Internet Information Server, Netscape and iPlanet servers. Many other servers have support for ISAPI, the Microsoft module interface (OmniHTTPd for example). If PHP has no module support for your web server, you can always use it as a CGI processor. This means you set up your server to use the command line executable of PHP (php.exe on Windows) to process all PHP file requests on the server.

Don't ever use the PHP cgi for windows, that's not meant for production use, it's not really meant for anything, don't use it, install the real SAPI module.

I think I see where you're going with this, you'd need root access to the server in this case. Don't know about telling IIS what language to use to run pages, but it's a good idea in general, what they don't know can't hurt them, LOL.

Good article comparing ASP.net and PHP. PHP 5 is especially interesting, the web will probably begin switching over to that sometime this year, it's gotten fairly well tested now.

Note the point about backward compatibility. That's another area MS will offer your company no support in. Every 5 years or so MS COMPLETELY REDOES its programming languages, they did this from VB 6 to vb.net, there was a big uproad, since everyone had to relearn the language, rewrite their programs, etc. PHP is much more conservative, it keeps working especially if you follow good programming practices in the first place, like not using globals, probably the absolute top number one errors of script kiddies around the planet. PHP 5 assumes globals are turned off, correctly.

Major apps will need full rewrites due to this sloppy programming, those apps include: phpbb, wordpress, which is possibly one of the worst out there in this regard, along with oscommerce. These problems can be avoided by not using bad programming practice.

Re sql, each db has a slightly different set of supported statements, you have to learn each individually, although the general ones are the same across the board, it's a pretty easy syntax, but don't let that fool you into thinking it's easy, it's not.

Programming of any sort, if you're serious about it, requires education, no education, no real understanding, it's pretty basic. There is no substitute for a real programming class. That's a class that is taught well, that's hard, with a good teacher. A bad programming teacher is basically useless, waste of time.

I went to the computer lab at my local college and asked the geeks there who the best programming teacher was, and that's who I studied with.
Back to top
Display posts from previous:   
Page: 1, 2  Next
All times are GMT - 8 Hours