dounao1875 2012-09-25 19:50
浏览 54

PHP表单处理

I've built a registration form, and I have implemented the jQuery Validation plugin by JÖRN ZAEFFERER, including stylizing the error messages with CSS, I want now to add a layer of PHP to validate a second time, in case JS is turned off then following that I will run the data through security : hash/salt/encryption etc, before inserting the data into a mySql table, then writing a program to get the account verified by email as part of the sign up process.

I'm self-taught so can anyone with more experience explain the best practices with this process. Questions I have are : Where should the PHP go, embed in the html file, in a seperate php file which the form action = "" submits to, or in an include file? What are the best practices as regards security, if I'm using a salt or a hash or an encrytion function should that be in an include file? The final question is : Is jQuery validation a waste of time, would it be better just to do it with PHP, if you do both, does the PHP embed itself in a HTML file or is it better for security to put it elsewhere.

This is the first time I've done this, but it's just simply taking input putting it in the database securely, verifying by email, and then logging in the new user to then go and use the website.

I'd love to know best practices to begin with, so if there are any good articles on the web, please link me to them.

Thanks

Ant Power

  • 写回答

2条回答 默认 最新

  • dongyizhui0616 2012-09-25 19:57
    关注

    Best practise would be to create a php function or class method that validates the data, and then calling said function/method in a seperate file defined as your form action. Assuming this is a POST request, you should have a seperate file handling the request. Validation should not be a part of this file, as you should be able to use it anywhere you want.

    TLDR: Create a validation class, and include and use it in a seperate processing file.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型