RE: [PHP] Can If Else statements be split into code blocks??
| From: | Richard Black | Date: | Tue, 13 Nov 2001 09:25:56 +0000 |
| Subject: | RE: [PHP] Can If Else statements be split into code blocks?? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-74392@lists.php.net to get a copy of this message | ||
Try putting curly brackets around the if and else clauses. I'm guessing the
embeded html form counts as another statement in the program, which means
you want to execute 2 statements if the strstr is true. I ALWAYS use curly
brackets, even if I'm only executing one statemenet in my if, and I've
never had problems with stuff like this.
So...
<?php
if (strstr($DomResults,$Match)) {
print "Congratulations! $domain.$suffix is available!";
?>
<form method="POST" action="step2.asp" name="form2">
<p><input type="submit" value="Register"
name="B1"></p>
</form>
<?php
}
else {
print "Sorry, $domain.$suffix is already taken.";
}
?>
Should hopefully work...
Richy
-----Original Message-----
From: Brad Melendy [SMTP:brad@techkno.com]
Sent: 13 November 2001 09:16
To: php-general@lists.php.net
Subject: [PHP] Can If Else statements be split into code blocks??
Hello,
I'm trying to execute some HTML in an IF ELSE statement. I'm trying
something like:
<?php
if (strstr($DomResults,$Match))
print "Congratulations! $domain.$suffix is available!";
?>
<form method="POST" action="step2.asp" name="form2">
<p><input type="submit" value="Register"
name="B1"></p>
</form>
<?php
else
print "Sorry, $domain.$suffix is already taken.";
?>
Basically, it works great without the form I'm trying to insert, but with
the form after the IF statement, it fails. Is what I want to do against
the
rules? I'm converting an ASP script I have to PHP and I have it all
working
under ASP. That means it should be eaiser with PHP right? ;-) Thanks in
advance.
...Brad
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net