开发者

Decide according to the condition and display the content dynamically in HTML with PHP

Whenever error occurs, I need to display the exception message in HTML page.

Basically my HTML page has a 开发者_开发问答form called "My_formG".

I need to display the exception content ( or at least a normal statement/sentence "try it again") above the form "My_formG".

For that I tried the code,

    <html>
    <body>
    <?php

    $MyexceptionOverFlow=1;

    if(isset($MyexceptionOverFlow))
    {
    ?>
   <div>
   <?php echo " OVER FLOW EXCEPTION.......  ";?>      
   </div>
   <?php
   }
   ?>
   <form id="My_formG">
   Enter your name: 
  <input type="text" id="id1">
  </form>
  </body>
  </html>

Output:

I am getting only the content of My_formG.

But I need content from both to be displayed. (I think the content of the if block is getting overwritten by the form. Is it so??).


This works just fine for me:

<html>
<body>
<?php
$MyexceptionOverFlow = 1;

if($MyexceptionOverFlow){ ?>
<div>
<?php echo " OVER FLOW EXCEPTION.......  "; ?>
</div>
<?php } ?>
<form id="My_formG">
Enter your name:
<input type="text" id="id1">
</form>
</body>
</html>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜