Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/239.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 防止表单提交时输入为空?_Php_Javascript_Jquery_Html_Css - Fatal编程技术网

Php 防止表单提交时输入为空?

Php 防止表单提交时输入为空?,php,javascript,jquery,html,css,Php,Javascript,Jquery,Html,Css,可能重复: 在客户端捕获提交的空输入(如副本中所示)可能是一个额外的功能,但您无法回避在服务器端执行此操作。if($\u POST['nt']==“”){echo'error';}可能重复(…或此处的任何类似问题;例如)在简单的web搜索中研究基本表单验证并不难。在这里发布问题之前,至少表现出一点努力 <?php include '../core/init.php'; if(isset($_POST['nt']) && isset($_POST['ntb'])){ m

可能重复:



在客户端捕获提交的空输入(如副本中所示)可能是一个额外的功能,但您无法回避在服务器端执行此操作。

if($\u POST['nt']==“”){echo'error';}
可能重复(…或此处的任何类似问题;例如)在简单的web搜索中研究基本表单验证并不难。在这里发布问题之前,至少表现出一点努力
<?php

include '../core/init.php';
if(isset($_POST['nt']) && isset($_POST['ntb'])){
mysql_query("INSERT INTO `post` (`myid`, `text`) VALUES ('".$_SESSION['id']."', '".mysql_real_escape_string($_POST['nt'])."')");
}
?>

<iframe style="display:none" name="submissiontarget" id="submissiontarget"></iframe>
<form method="post" target="submissiontarget" action = "../ajax/post.php" name="form">
<input type="textbox" name="nt" class="postwall" id="nt"  placeholder="Post on your wall" rows="7" wrap="physical" cols="40" onfocus="if(this.value=='Post On Your Wall')this.value='';" onblur="if(this.value=='')this.value='Post On Your Wall';" />
<input type="submit" style="display:none;" name='ntb' id='ntb'  class="Buttonchat"     value="Post" />
</form>
if(isset($_POST['nt']) && isset($_POST['ntb'])) {
    …
} else {
    echo "There was an error posting on your wall, please try again.";
}