search
Homephp教程php手册请假下各位php表单有关问题

请假下各位php表单问题 PHP代码submit.php 这个代码存在的问题,只要刷新submit.php这个页面就会不断往数据库中添加空白数据,请问(我是小白太高级的目前还不懂)该如何增加对字段验证或者增加验证码功能 ?php /** *@处理表单提交数据 */ define('INCLUDE_CH

请假下各位php表单问题
PHP代码submit.php
这个代码存在的问题,只要刷新submit.php这个页面就会不断往数据库中添加空白数据,请问(我是小白太高级的目前还不懂)该如何增加对字段验证或者增加验证码功能
<?php<br />
/**<br />
 * @处理表单提交数据<br />
*/<br />
define('INCLUDE_CHECK',1);<br />
require_once('connect.php');<br />
$name=stripslashes($_POST['name']);<br />
$tel=stripslashes($_POST['tel']);<br />
$ask=stripslashes($_POST['ask']);<br />
$des=stripslashes($_POST['des']);<br />
$time=date('Y年m月d日H时i分s秒',time());<br />
<br />
$url=stripslashes($_POST['url']);<br />
$query=mysql_query("insert into say(name,tel,ask,des,time,url)values('$name','$tel','$ask','$des','$time','$url')");<br />
?>


------解决思路----------------------
$query=mysql_query("insert into say(name,tel,ask,des,time,url)values('$name','$tel','$ask','$des','$time','$url')");这一段代码放在一个if条件判断里面。  在判断中进行对应的条件判断,比如$name != "" 这样。
------解决思路----------------------
如果有post数据就执行数据库插入,否则不执行if(isset($_POST['name']) && !empty($_POST['name'])){
$query=mysql_query("insert into say(name,tel,ask,des,time,url)values('$name','$tel','$ask','$des','$time','$url')");
}
------解决思路----------------------
在前台表单的submit按钮上加一个value
后台判断$_post['submit']是否有值

<br />
if($_post['submit']){<br />
表单提交操作<br />
}else{<br />
不是提交操作<br />
}<br />
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor