doushi1996 2013-06-30 15:41
浏览 26

表格验证 - 标准解决方案?

I'm a little above a newbie with web programming and I don't know much about form validation. In my research, it seems that there are a variety of ways to validate form data and some of the methods depend on what you're going to do with the data. Then you have to-be deprecated functions like mysql_real_escape_string and something called "PDO" and the whole thing is downright complicated.

So, would it be reasonable/feasible for there to be a set of functions that are basically the standard way to validate form data? Like this...

function validate_for_sql()
function validate_for_email()
function validate_for_browser()

Maybe there should be more (something for integers?). The ideal would be things like sql injections and other nasties could ALL be handled via a set of generally accepted and rock-solid functions developed by and for the coding community.

Is this doable? Does it already exist somewhere.. maybe in a hidden lair? If so, can someone email me the secret password needed to access this information? :)

  • 写回答

3条回答 默认 最新

  • dongyan2267 2013-06-30 15:47
    关注

    If I understand your question, then yes, this is possible by passing values of similar type inputs as parameters into functions. I'm sure if you search the web you'll find some pre-made functions that will do this. But, they don't take that long to make, plus creating them will enhance your skills. It would be good to have something like that, and as a matter of fact, ASP.NET actually does have inbuilt validation, but I'm afraid PHP does not (as far as I know).

    评论

报告相同问题?

悬赏问题

  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败