Hi !
This is an extract of my php code :
if ($changecheck != "1")
{
if (!$login || !$passe)
{
echo 'You must enter your login and password.<br />'
.'Please go back and try again.';
exit;
} }
else
{
if (!$login || !$passe || !$npasse || !$npasse2)
{
echo 'You must enter all the fields.<br />'
.'Please go back and try again.';
exit;
}
if ($npasse !== $npasse2)
{
echo 'You have made a mistake while entering the passwords.<br />'
.'Please go back and try again.';
exit;
}
}
which is in the middle of an HTML code. The problem is that each time that the condition choosen by the web user arrives on an "exit", the rest of the HTML code isn't executed. Which command could I use instead of "exit" ? I've tried "break / continue", it doesn't work...
Who can help ?
problem with if condition
Moderator: General Moderators
- orangeapple
- Forum Commoner
- Posts: 70
- Joined: Tue Jan 06, 2004 1:24 pm
- Location: Geneva / Switzerland
- dull1554
- Forum Regular
- Posts: 680
- Joined: Sat Nov 22, 2003 11:26 am
- Location: 42:21:35.359N, 76:02:20.688W
i'd do this
i thing thats the easiest way or you could set the bunches of HTML to $vars
ex.
$html1 = <<< EOT
//bunch of html
EOT;
then just echo the var where ever you need it
Code: Select all
//bunch of HTML
if (!$login || !$passe)//personally i'd use !isset()
{
echo 'You must enter your login and password.<br />'
.'Please go back and try again.';
//other bunch of HTML
exit;
}ex.
$html1 = <<< EOT
//bunch of html
EOT;
then just echo the var where ever you need it
- orangeapple
- Forum Commoner
- Posts: 70
- Joined: Tue Jan 06, 2004 1:24 pm
- Location: Geneva / Switzerland
- dull1554
- Forum Regular
- Posts: 680
- Joined: Sat Nov 22, 2003 11:26 am
- Location: 42:21:35.359N, 76:02:20.688W
yeah thats exactly what i mean, but what would be easier is this;
Code: Select all
$html = <<< EOT
//the html you want to be after the if statement
EOT;
//then do this
if (!$login || !$passe)
{
echo 'You must enter your login and password.<br />'
.'Please go back and try again.';
echo $html;
exit;
}- orangeapple
- Forum Commoner
- Posts: 70
- Joined: Tue Jan 06, 2004 1:24 pm
- Location: Geneva / Switzerland