it-swarm.com.de

Warum erhalte ich in dieser Vorlage einen unerwarteten Syntaxfehler "endwhile" (T_ENDWHILE)?

Ich versuche, ein Formular zu wiederholen. Wenn der Benutzer angemeldet ist, wird dies im Browser angezeigt, wenn ich den Code hochlade:

syntax error, unexpected 'endwhile' (T_ENDWHILE) in

Mein Code:

<?php
/*
Template Name: Customers
*/

get_header(); ?>

    <div id="primary" class="site-content">
        <div id="content" role="main">

            <?php while ( have_posts() ) : the_post(); ?>
                <?php get_template_part( 'content', 'page' ); ?>
                <?php if (is_user_logged_in()):

echo '<form type="post" action="" id="newCustomerForm"> ';

echo '<label for="name">Name:</label>';
echo'<input name="name" type="text" />';

echo'<label for="email">Email:</label>';
echo'<input name="email" type="text" />';

echo'<label for="phone">Phone:</label>';
echo'<input name="phone" type="text" />';

echo'<label for="address">Address:</label>';
echo'<input name="address" type="text" />';

echo'<input type="hidden" name="action" value="addCustomer"/>';
echo'<input type="submit">';
echo'</form>';
echo'<br/><br/>';
echo'<div id="feedback"></div>';
echo '<br/><br/>';

else:
echo 'Sorry, only registered users can view this information';
?>

            <?php endwhile; // end of the loop. ?>

        </div><!-- #content -->
    </div><!-- #primary -->

<?php get_sidebar(); ?>
<?php get_footer(); ?> 
2
mattnewbie

Ihnen fehlt ein <?php endif; ?>

[...]

else:
echo 'Sorry, only registered users can view this information';

endif;

<?php endwhile; // end of the loop. ?>

[...]
2
kraftner

Sie haben vergessen, die Anweisung if zu beenden. das sollte funktionieren:

   <div id="primary" class="site-content">
        <div id="content" role="main">

            <?php while ( have_posts() ) : the_post(); ?>
                <?php get_template_part( 'content', 'page' ); ?>
                <?php if (is_user_logged_in()):

echo '<form type="post" action="" id="newCustomerForm"> ';

echo '<label for="name">Name:</label>';
echo'<input name="name" type="text" />';

echo'<label for="email">Email:</label>';
echo'<input name="email" type="text" />';

echo'<label for="phone">Phone:</label>';
echo'<input name="phone" type="text" />';

echo'<label for="address">Address:</label>';
echo'<input name="address" type="text" />';

echo'<input type="hidden" name="action" value="addCustomer"/>';
echo'<input type="submit">';
echo'</form>';
echo'<br/><br/>';
echo'<div id="feedback"></div>';
echo '<br/><br/>';

else:
echo 'Sorry, only registered users can view this information';
?>

            <?php  endif;?>
            <?php endwhile; // end of the loop. ?>


        </div><!-- #content -->
    </div><!-- #primary -->

<?php get_sidebar(); ?>
<?php get_footer(); ?> 
2
user48752