De ce primesc eroarea de sintaxă 'unexpected endwhile' (T_ENDWHILE) în acest template?
2 apr. 2014, 18:08:08
Vizualizări: 17.3K
Voturi: 2
Încerc să afișez un formular când utilizatorul este autentificat, dar primesc această eroare în browser când încarc codul:
syntax error, unexpected 'endwhile' (T_ENDWHILE) in
Codul meu:
<?php
/*
Template Name: Clienți
*/
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">Nume:</label>';
echo'<input name="name" type="text" />';
echo'<label for="email">Email:</label>';
echo'<input name="email" type="text" />';
echo'<label for="phone">Telefon:</label>';
echo'<input name="phone" type="text" />';
echo'<label for="address">Adresă:</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 'Ne pare rău, doar utilizatorii înregistrați pot vedea această informație';
?>
<?php endwhile; // sfârșitul buclei. ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>

User
100
Toate răspunsurile la întrebare
2
0
Ai uitat să închizi instrucțiunea if
. Acesta ar trebui să funcționeze:
<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">Nume:</label>';
echo'<input name="name" type="text" />';
echo'<label for="email">Email:</label>';
echo'<input name="email" type="text" />';
echo'<label for="phone">Telefon:</label>';
echo'<input name="phone" type="text" />';
echo'<label for="address">Adresă:</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 'Ne pare rău, numai utilizatorii înregistrați pot vedea această informație';
?>
<?php endif;?>
<?php endwhile; // sfârșitul buclei. ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>

user48752
46
2 apr. 2014 18:25:58
Întrebări similare
3
răspunsuri
1
răspunsuri