gpt4 book ai didi

即使表单中有字段,PHP 表单也会返回错误

转载 作者:行者123 更新时间:2023-11-28 04:00:26 25 4
gpt4 key购买 nike

PHP代码:

<html>
<head>
<head>
</head>
<body bgcolor="000033" text="navy">
<?php
$nume="";
$email="";
$subiect="";
if (!$nume || !$email || !$subiect)
{
?>
<h4 style="color:gray" align="center">
Eroare: Toate campurile sunt obligatorii!</h4>
<p align="center">
Corectati <a href="javascript:history.go(-1)">formularul</a>
</p>
<?
}
else{
?>
<h4 style="color: green;" align="center">
Formularul introdus </h4>
<hr size="1" width="75%">
<?
$mesaj = "";
$mesaj .= "<impresie data=\"". date("d M Y, G:i");
$mesaj .= "\" client = \"" . $REMOTE_HOST . "(" . $REMOTE_ADDR . ")\">\n";
$mesaj .= "<nume email=\"" . $email . "\">" . $nume . "</nume>\n";
if ($subiect)
$mesaj .= "<text>\n" . $subiect . "\n</text>\n</subiect>\n";
mail("sitecurs18@gmail.com", "subiect", $mesaj, "from:". $email);
}
?>
<hr size="1" width="75%">
</body>
</html>

表单代码:

<html>
<head>
<title>Contact</title>
<style type="text/css">
body {background-color: 000033;
}
table {margin-top: 10px;}
</style>
</head>
<body>
<form action="prelucrare.php">
<table width="800" align="center" rows="5" cols="3" cellspacing="0" border="0">
<tr>
<td bgcolor="gray" colspan="3"><font face="serif" color="000033" size="+3">Contact</font></td>
</tr>
<tr>
<td width="175" height="65" align="left" valign="center"><font face="arial" color="gray"size="3"><p>Numele &#351;i prenumele:</p></font></td>
<td width="225" align="left" valign="center"><input name="nume" type="text" value=""></td>
</tr>
<tr>
<td height="65"><font face="arial" color="gray" size="3"><p>Adresa e-mail:</p></font></td>
<td><input name="email" type="text" value=""></td>
</tr>
<tr>
<td height="65"><font face="arial" color="gray" size="3"><p>Subiect:</p></font></td>
<td><textarea rows="6" cols="40" name="subiect"></textarea></td>
</tr>
<tr>
<td height="65" align="right"><input type="submit" value="Trimite"></td>
<td align="center"><input type="reset" value="&#350;terge"></td>
</tr>
</table>
</form>
</body>
</html>

当我提交表单时,它会直接将我带到错误页面,显示我没有填写所有字段,我尝试了所有方法但无法修复。

我试过将字段的变量定义为空,但它什么也没改变,还尝试从

更改 php 标签

最佳答案

您需要读取表单变量并将它们分配给您的 php 变量。您没有提到方法类型,即获取或发布。默认情况下它是 get 所以使用 get 来读取表单值是这样的:

$nume = $_GET["nume"];
$email = $_GET["email"];
$subiect = $_GET["subiect"];

如果您想在您的表单中发布提及 method=post 并将 get 替换为 post 以读取值。

关于即使表单中有字段,PHP 表单也会返回错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43239689/

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