Perché ricevo l'errore di sintassi "unexpected 'endwhile' (T_ENDWHILE)" in questo template?
2 apr 2014, 18:08:08
Visualizzazioni: 17.3K
Voti: 2
Sto cercando di visualizzare un form quando l'utente è loggato, ma ottengo questo errore nel browser quando carico il codice:
syntax error, unexpected 'endwhile' (T_ENDWHILE) in
Il mio codice:
<?php
/*
Template Name: Clienti
*/
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">Nome:</label>';
echo'<input name="name" type="text" />';
echo'<label for="email">Email:</label>';
echo'<input name="email" type="text" />';
echo'<label for="phone">Telefono:</label>';
echo'<input name="phone" type="text" />';
echo'<label for="address">Indirizzo:</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 'Spiacente, solo gli utenti registrati possono visualizzare queste informazioni';
?>
<?php endwhile; // fine del loop. ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>

User
100
Tutte le risposte alla domanda
2
0
Hai dimenticato di chiudere l'istruzione if
. Questo dovrebbe funzionare:
<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">Nome:</label>';
echo'<input name="name" type="text" />';
echo'<label for="email">Email:</label>';
echo'<input name="email" type="text" />';
echo'<label for="phone">Telefono:</label>';
echo'<input name="phone" type="text" />';
echo'<label for="address">Indirizzo:</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 'Spiacente, solo gli utenti registrati possono visualizzare queste informazioni';
?>
<?php endif;?>
<?php endwhile; // fine del loop. ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>

user48752
46
2 apr 2014 18:25:58
Domande correlate
3
risposte
1
risposte