我的php文件有点问题就在这里。表格的标题应该是" Inregistrare"但总是在页面显示">它不应该。此外,提交表单不会显示错误消息,而在Chrome中,它只显示代码,就像文本文件一样。能帮我解决一下吗? PHP:
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<link rel="icon" type="image/gif" href="icon.png">
<title>Înregistrare</title>
<link rel="stylesheet" type="text/css" href="resources.css">
</head>
<body>
<?php
require_once 'config.php';
$user= $email = $pass = $cpass = "";
$usererr = $emailerr = $passerr = $cpasserr = "";
$user=trim($POST["username"]);
$pass=trim($POST["pass1"]);
$cpass=trim($POST["pass2"]);
$email=trim($POST["email"]);
if($_SERVER["REQUEST_METHOD"] == "POST"){
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailerr = "Intoduceți o adresă de email validă.";
}
else if(empty($email)){
$usererr = "Introduceți un nume de utilizator.";
}
if(empty($user)){
$usererr = "Introduceți un nume de utilizator.";
}
else if(!preg_match("/^[a-zA-Z0-9] *$/",$user)){
$usererr = "Folosiți doar cifre sau litere.";
}
else{
mysqli_stmt_bind_param($stmt, "s", $user);
if(mysqli_stmt_execute($stmt)){
mysqli_stmt_store_result($stmt);
if(mysqli_stmt_num_rows($stmt) == 1){
$usererr = "Acest nume de utilizator nu este disponibil.";
}
} else{
echo "Oops! Ceva nu a mers bine. Te rugăm să încerci mai târziu.";
}
mysqli_stmt_close($stmt);
}
if(empty($pass)){
$passerr = "Introduceți o parolă.";}
elseif(strlen($pass) < 6){
$passerr = "Parola trebuie să aiba cel puțin 6 caractere.";
}
if(empty($cpass)){
$cpasserr = 'Vă rugăm confirmați parola.';}
if($pass != $cpass){
$cpasserr = 'Parolele nu se potrivesc.';
}
//if(empty($usererr) && empty($passerr) && empty($cpasserr)){
}
?>
<div class ="box">
<h2>Înregistrare<h2>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>">
<input type="text" style="border-radius: 5px; border-color: #333; border-width: 1px; margin-top: 10px; width: 230px; height: 30px; margin-left: 10px; margin-right: 10px;" name="username" placeholder="Nume de utilizator"><br><span class="errmsg"><?php echo $usererr; ?></span><br>
<input type="text" style="border-radius: 5px; border-color: #333; border-width: 1px; margin-top: 10px; width: 230px; height: 30px; margin-left: 10px; margin-right: 10px;" name="email" placeholder="Adresă de e-mail"><br><span class="errmsg"><?php echo $emailerr; ?></span><br>
<input type="password" style="border-radius: 5px; border-color: #333; border-width: 1px; margin-top: 10px; width: 230px; height: 30px; margin-left: 10px; margin-right: 10px;" name="pass1" placeholder="Parolă"><br><span class="errmsg"><?php echo $passerr; ?></span><br>
<input type="password" style="border-radius: 5px; border-color: #333; border-width: 1px; margin-top: 10px; width: 230px; height: 30px; margin-left: 10px; margin-right: 10px;" name="pass2" placeholder="Confirmare parolă"><br><span class="errmsg"><?php echo $cpasserr; ?></span><br>
<input class="signandlog" type="submit" value="Înregistrare">
<p style="font-size: 12px; font-family: Calibri; color: black;"> Ai deja un cont? <a style="font-size: 12; color: orange; text-decoration:none;" href="login.php">Conectare</a></p>
</form>
</div>
</body>
</html>
CSS:
.box {
margin-top: 50px;
border-radius: 10px;
border: solid;
border-width: 2px;
margin-left: 40%;
border-color: #222;
width: 550px;
height: 370px;
font-family: Calibri;
text-align: center;
}
.signandlog {
margin-top: 15px;
border-style: solid;
border-radius: 6px;
border-width: 1px;
border-color: #1065e1;
background-color: #1065e1;
height: 40px;
width: 130px;
color: white;
font-family: Calibri;
font-size: 15px;
}
.signandlog:hover {
border-style: solid;
border-radius: 6px;
border-width: 1px;
border-color: #1065e1;
color: #1065e1;
background-color: white;
}
.errmsg
{
color: red;
font-family: Calibri;
font-size: 15px;
}
答案 0 :(得分:0)
关闭<h2>
的标记,如
<h2>Înregistrare</h2>