0

I have a little problem with a php file right here. The title of the form it should be "Inregistrare" but always after that the page shows "> and it shouldn't. Also the submission form does not show error messages and in Chrome it just shows the code it like a text file. Can you please help me figure it out? 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;
}
Antoniu Fic
  • 39
  • 1
  • 3
  • PHP configured on your web server? [PHP code is not being executed, instead code shows on the page](https://stackoverflow.com/questions/5121495/php-code-is-not-being-executed-instead-code-shows-on-the-page) – ficuscr May 10 '18 at 20:58

1 Answers1

0

Close the tag of <h2> like

<h2>Înregistrare</h2>
Friday Ameh
  • 1,551
  • 1
  • 8
  • 15