English 中文(简体)
处理复杂情况的最佳方式,其形式是多重提交和搜索
原标题:Best way to handle complex scenario in form with multiple submit and search
  • 时间:2011-11-23 15:00:47
  •  标签:
  • php
  • forms

我要问,对于我来说,处理这种局面的最佳方式和方式是多么复杂。 也许值得高度赞赏。

the page that i want to build should have this features.

  1. can be open in browser via http://server/view.php?id=1000
  2. if id=1000 does not exist, post a message not exist and throw it to another page
  3. if id=1000 does exist, then open the page for viewing
  4. the page has a form with with a textbox where i can add info about the records
  5. the form submit to itself and process the data to DB.

如何将所有这些特点结合起来? i 是否真的赞赏特别是提交表格的样本尼佩特代码,如果通过抽签可以查到。

最佳回答

以下非常基本的例子。 你可以填写详细情况

$id = intval($_GET[ id ]);  // assume it s int and force to be int

// do database call
// 1. init connection, set db, etc
mysql_query("select something from something where id = ".$id);

// check for results
if (! results exist) http_redirect( your error page );

// Now check if any posted variables exist
if (isset($_POST[ field1 ]) && isset($_POST[ field=2 ]) .... 
{
   1. validate your data
   2. insert to the database
   3. http_redirect to success page
}

// if you re getting here, that means id is valid and data has not been posted
 show your form
 display whatever HTML you need with the data loaded for id above
问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签