PHP error I that I don't understand

Hi,

this is probably something very simple, but I have tried for quite a while to fix it and have come up short. I have the following nested if… else segment, but for some reason PHP complains about the last else.

  <?php
  if ( $user = $kirby->user() ){
  	if ($user->name() != ""){ ?>
		<div class="greeting">Hello <?= $user->name() ?>! <form action="<?= $page->url() ?>" method="POST"><input type="submit" name="logout" value="Logout"></form></div>
		<?php } else { ?>
		<div class="greeting">You are logged in!  <form action="<?= $page->url() ?>" method="POST"><input type="submit" name="logout" value="Logout"></form></div></div>
	}?>
		
		<?php if($success) { ?>
        <div class="alert success">
            <p><?= $success ?></p>
			<p><?= $output ?></p>
        </div>
        <?php } elseif (isset($alert['error'])) { ?>
            <div><?= $alert['error'] ?></div>
		<?php } ?>
	
  	<form action="<?= $page->url() ?>" method="POST">
  		<label for="url">URL:</label>
  		<input type="text" id="url" name="url" value="<?= esc($data['url'] ?? '', 'attr') ?>" required>
  		<input type="submit" name="submit" value="Submit">
  	</form>
  <?php } else { ?>
	  <div class="greeting"><form action="<?=$page->url()?>" method="POST"><input type="submit" name="login" value="Login"></form>'
<?php }; ?>

Can someone please help me see the error of my ways?

This line misses an opening statement.

Personally, I find this hard to read and we recommend using the following syntax

<?php if ($x === $z): ?>
<!-- something here -->
<php endif; ?>

Apart from that, the elseif for the alert can be replaced with a simple if

That missing opening statement did me in. I would have spent another day or so to see that one. Thanks. :slight_smile: