Jump to content

HTML code dissaperaing after PHP code


soma56

Recommended Posts

I have a page that contains html and php. When the php is called everything beneath it (all the html) disappears.

Here's an example:

 

<html>
<body>

<form action="" method="post">
<table width="500">
<tr><td>What's your name?<input name="name" type="text" /></td></tr>
<tr><td><input type=Submit value="Enter Name" name="Submit"></td></tr>

<?PHP

if (isset($_POST['Submit'])) {

echo $name;

unset($targetkeyword);

}

?>
</table></form>


<table width="500">
<tr><td>This text is not displayed when and after PHP function is set</td></tr>
</table>
</body>
</html>

 

When the page initially loads I can see everything however once the submit button is clicked everything after the php code is gone - even after the PHP has completed doing it's thing.

Link to comment
https://forums.phpfreaks.com/topic/206643-html-code-dissaperaing-after-php-code/
Share on other sites

I think it's because you're trying to echo something within the table's structure, but not echoing the proper <tr><td></td></tr> structure with it, thereby breaking the table structure.

 

if (isset($_POST['Submit'])) {

 

    echo "<tr><td>{$_POST['name']}</td></tr>";

 

unset($targetkeyword);

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.