gpt4 book ai didi

php - PHP文本框为空

转载 作者:行者123 更新时间:2023-12-03 08:47:45 25 4
gpt4 key购买 nike

I has read all the various post on StackOverflow regards this same but that was not helpful ...



当文本框为空或格式无效时,PHP脚本不显示错误警报。我只知道下面提到的空脚本,但是我也不知道如何添加模式错误。

另外,当文本框为空时,为什么不显示错误?请帮忙。请不要将其标记为重复,因为我阅读了各种文章,但同样的问题也就是为什么我发布了主题。请提供完整的脚本帮助。

提前谢谢你。
 <?php
if(isset($_POST['submit']))
{
$name= $_POST['name'];
if (!($name))
{
$m1 = "<Div class="alert">Enter your Name</Div>" ;
}

$email= $_POST['email'];
if (!($email))
{
$m2 = "<Div class="alert">Enter Your Email"</Div> ;
}

$_SESSION['name'] =$name;
$_SESSION['email'] =$email;
$_SESSION['otp']=$rndno;
header( "Location: next-page.php" );
}
?>

在HTML正文中
<div>
<?php if(isset($m1)) { echo $m1; } ?>
<?php if(isset($m2)) { echo $m2; } ?>
</div>

最佳答案

试试这个代码是可运行的

<?php
if(isset($_POST['submit']))
{
$name= $_POST['name'];
if ( $name == '')
{
echo $m1 = "<script type='text/javascript'>alert('Please Enter Your Name');</script>" ;
}

$email= $_POST['email'];
elseif ( $email == '')
{
echo $m2 = "<script type='text/javascript'>alert('Enter Your E-mail');</script>" ;
}

$_SESSION['name'] =$name;
$_SESSION['email'] =$email;
$_SESSION['otp']=$rndno;
else{
header( "Location: next-page.php" );
}
}

?>

关于php - PHP文本框为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50036742/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com