0

how can i echo this code. when i echo it it prints out the html tags and <? php code ?> i want to echo the html code and interpret the php as php.

echo "<h2>Add Contact</h2>
	<form name=\"form1\" action=\"<?=$_SERVER[\'PHP_SELF\'];?>?mode=added\" method=\"post\">
	<table class=\"tableStyleClassTwo\">
	<tr><td>Name:</td><td><div align=\"left\">
	<input type=\"text\" name=\"name\" />
	</div></td></tr>
	<tr><td>Phone:</td><td><div align=\"left\">
	<input type=\"text\" name=\"phone\" />
	</div></td></tr>
	<tr><td>Email:</td><td><div align=\"left\">
	<input type=\"text\" name=\"email\" />
	</div></td></tr>
	<tr><td colspan=\"2\" align=\"center\"><a href=\"javascript:history.go(-1);\">Back</a> | <input name=\"Submit\" type=\"submit\" id=			\"Submit\" value=\"Add New Contact\" <?php if($disable ==1){?>disabled<?php } ?>/></td></tr>
	<input type=\"hidden\" name=\"mode\" value=\"added\">
	</table>
	</form>";
5
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by SKANK!!!!!
0

First of all, you don`t need to put the <?php and ?> tags in echo.
Second of all, try replacing " with '
If it won`t work, you need to separate the html strings for the php using: .

0

so basically someithin like this, but when i put the "." in front of the <? it still doesnt work?

echo'
	<h2>Add Contact</h2>
	<form name="form1" action=".<?=$_SERVER[\'PHP_SELF\'];?>?mode=added" method="post">';
0

so basically someithin like this, but when i put the "." in front of the <? it still doesnt work?

echo'
	<h2>Add Contact</h2>
	<form name="form1" action=".<?=$_SERVER[\'PHP_SELF\'];?>?mode=added" method="post">';

why you are using still php tag in echo
remove first...write like this.

<form name="form1" action=".$_SERVER[\'PHP_SELF\']."?mode=added" method="post">';
0

after removing <? ?> tags then use htmlentities function to output html code on browser.

echo htmlentities("your html string");

0

u dont put <?php and ?> in php variables.
you have to insert a variable like the person above stated

<?php echo $variable; ?>
<?php echo "my variable is ".$variable; ?>
or
<?php echo "my variable is $variable; ?> sometimes works.
and then u can do it this way:
<?php echo "my variable is ".$variable."."; ?>
which is the one u should use because u dont end the echo with the $variable

some people told me that u have to have spaces when u insert a variable like this:

<?php echo "my variable is " . $variable . " but i hate echoing my variable this way"; ?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.