Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.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_Html_Arrays_Forms - Fatal编程技术网

Php 如果按钮上的文本区域为空,提交将显示成功消息

Php 如果按钮上的文本区域为空,提交将显示成功消息,php,html,arrays,forms,Php,Html,Arrays,Forms,我试图在单击submit按钮时获取错误消息,但仅从文本字段获取消息,而不是从文本区域获取消息。这是我的密码 问题是,如果我提交没有文本区域的字段,将显示成功。请帮忙 if(empty($_POST)===false) { if(empty($_POST['offered'])===true||($_POST['description']===true)) { ?>

我试图在单击submit按钮时获取错误消息,但仅从文本字段获取消息,而不是从文本区域获取消息。这是我的密码

问题是,如果我提交没有文本区域的字段,将显示成功。请帮忙

    if(empty($_POST)===false)
    {
            if(empty($_POST['offered'])===true||($_POST['description']===true))
            {
?>                    
               <div class="alert alert-warning alert-dismissible text-center" role="alert">
                <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>Add some offers and descriptions
                </div>
 <?php                  
            }
            else
            {
                $title=$_POST['offered'];
                $offer=$_POST['description'];
                $data=array($page_id,$title,$offer);

                if($data)
                {   
                   $add=add_data($data); 
                   header('location:hotel1_galery.php?page_id=1 && msg=Add Offers Sucessfully'); 
                }
                else
                {
?>                           
                  <div class="alert alert-danger alert-dismissible text-center" role="alert">
                  <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span><?php echo "Add offers and descriptions "; ?></div>
<?php
                 }               
            }

        } 
?>
if(空($\u POST)==false)
{
if(空($_POST['offered'])==true | |($_POST['description']==true))
{
?>                    
添加一些优惠和说明
HTML

<form action="hotel1_galery.php?page_id=1" method="post" class="col-sm-4" role="form">
                            <div class="form-group has-info">
                                <label class="control-label" for="inputSuccess">Offer title
                                </label>
                                <input type="text" class="form-control" name="offered" id="offered" required>
                                <label class="control-label" for="inputSuccess">Offer Description
                                </label>
                                <textarea id="description" name="description" placeholder="Offer Description" class="form-control " rows="3" required>
                                </textarea>
                                <br>  
                                <button type="submit" class="btn btn-primary">
                                <span>SUBMIT
                                </span>
                                </button>
                            </div>
                            </form>

报盘标题
报价说明

提交
在这行中:

if(empty($_POST['offered'])===true||($_POST['description']===true))
您只需检查
$\u POST['offered']
是否为空,并且检查
$\u POST['description']
是否为
true
(不是您想要做的)。您还需要在
$\u POST['description']
上执行
empty()

if(empty($_POST['offered'])===true||empty($_POST['description'])===true)

如果我给出此代码,则如果所有字段都已填充,则无法给出成功消息

 if(empty($_POST['offered'])===true||empty($_POST['description'])===true)

如果我给出了此代码,那么如果所有字段都已填充,则无法给出成功消息