English 中文(简体)
多种表格,可检索PHP网页和表格验证
原标题:multiple forms accessing one PHP page and form validation

首先,与我没有法典。 I m收集需要数据以启动一个项目。

I will be having multiple <form>s on a website which are all linked to the same PHP page, say for example to send email or add data to DB.

现在,我可以建立表格,并用购买力平价网页向亚洲开发银行发送邮件或增加数据。 我需要知道......。 如果其中任何表格都指PHP网页,那么我如何知道为什么会这样做?

而且,对形式采取双重效力是否更好? 我指的是,客户方然后是服务器方?

Since we are talking about validation, is it better to be, on client-side, JS or JQuery (I can write both)? And about the DB thing, how can I secure it?!! I mean, how can I assure that the user won t enter a PHP code to mess things up and how I can detect it.

I know this seems to be like general question or a discussion, but you will be helping me a lot. And frankly, I ve been using this website for around 3 yrs now, and you guys helped me pass my grad project with a great grade :) So I m willing to find answers here :)

Thanks all.

最佳回答

你可以以你的形式使用隐蔽的领域来表示应该采取什么行动。 你们也可以将一个参数列入形式的行动特性。 要么是结果。

<form>
  <input type= hidden  name= mode  value= save >
  <!-- More HTML --> 
</form>

<form>
  <input type= hidden  name= mode  value= delete >
  <!-- More HTML --> 
</form>

为了进行验证,服务器的侧面验证首先进行,然后增加客户对面的验证,以减少服务器处理和减少往返时间。 人们将赞赏反应性的形式设计。 现有各种认证工具,只是研究这一问题的相关联系。

为安全起见,请您使用PDO。 黄金规则是逃避你们的投入,并标注你们的产出。 您可使用以下方法:htmlspecialchars()以编码你的产出。 并且利用PHP的过滤方法。 http://php.net/manual/en/book.filter.php rel=“nofollow”http://php.net/manual/en/book.filter.php。 此外,在进行验证工作时,通常最好把黑名单删除,而不是黑名单。

问题回答

如果你有多种提交同一页的表格,你可以通过在隐蔽的数据领域寄出表格,例如:

<input type="hidden" name="form_name" value="001" />

Input validation should ALWAYS happen on the server. Client-side validation is nice for your users, but server-side is a must.

在你做任何事情之前,对用户的投入加以验证,并酌情加以逃脱。 例如mysql_real_einski_string。 当你在问询时,或使用发言稿。

Have a hidden field in each to determine what the action is...

<input type="hidden" name="action" value="cart" />

页: 1

<input type="hidden" name="action" value="purchase" />




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签