search

Home  >  Q&A  >  body text

When PHP is mixing php and html, syntax error, unexpected end keeps appearing.

This problem keeps popping up, can anyone give me some advice? Where is the problem

The source code is as follows

<meta charset="utf-8"><?php if (isset($_POST['userName'])) { if (!empty($_POST['userName'])&&!empty( $_POST['passWord'])) { #Determine whether the entered user name and password are empty if ($_POST['userName'] == "zzh" && $_POST['passWord'] == "123") {# Determine whether the entered username and password is a certain value if (setcookie("name","zzh")) {//If it is a set value, issue a cookie echo "Login successful, welcome to visit!<a href= './index.php'≫ Back to the homepage & lt;/a & gt; ";} Else {echo" cookies failed! ";}} Else {echo" user name or password error! login.php'>Please log in again!</a>";  </a>";                                                                                                                                             gt; < ;meta charset="utf-8"></head><body>                                                                   "_blank"> input type="submit" name="userSubmit" value="Login"> <!--Submit button--> </form></body></html>HTML; //Represents HTML End echo $htm; }?>

P粉755083152P粉755083152582 days ago805

reply all(3)I'll reply

  • P粉755083152

    P粉7550831522023-04-24 13:41:39

    Thank you, boss!

    reply
    0
  • phpcn牛

    phpcn牛2023-04-24 13:09:37

    <<<Just add a space after it and start the HTML at the end on a new line.

    reply
    0
  • phpcn牛

    phpcn牛2023-04-24 13:07:57

    if (isset($_POST['userName'])) { if (!empty($_POST['userName'])&&!empty($_POST['passWord'])) { if ($_POST[' userName'] == "zzh" && $_POST['passWord'] == "123") { = './index.php' & gt; return home & lt;/a & gt; "} Else {echo" cookie! ";}} Else {echo" user name or password error! & lt; a href = '. /login.php'> Please log in again! & lt;/a & gt; ";}} Else {echo" user name or password error! & lt; a href = './login.php' & gt; /a>"; }}else{ $htm = <<< HTML ;             </head> ; ; ; Password: <input                                                                                                                     body>

    reply
    0
  • Cancelreply