Just wanted to ask you guys how to properly call HTML tags into php. e.g.

echo "You are not authenticated.  Please login.<br><br>
  
  <form method=POST action=admin.php bgcolor=\"C0C0C0\">
  username: <input type=text name=\"username\">
  password: <input type=password name=\"password\">
  <input type=submit>
  </form>";

As you can see above, the developer has design a form inside a the PHP inself. Where can I find useful resources on more examples on how to embed HTML into PHP.

*How to to do everything using echo statement

1. Any useful books?
2. Any useful links?

Recommended Answers

All 7 Replies

that example there is right but if you have alot of HTML it is faster to Not embed HTML in PHP but if you hsve to it is nothing special so you just need to do it the way you have in that example

This is just an example for the form. Where can I find more similar examples.

just do it in the same way, write out the HTML tags within an echo and if you need to use a double quote(") or a single quote(if that is how you opened the echo)(') then put a (\) in front of it, you dont need an example

if it helps you:

echo "<p>Here is some text displayed in a paragraph tag </p>";

$str = "<table width='90%' align='center' border='1'>";
$str .= "<tr>";
$str .= "<td>some text here</td>";
$str .= "</tr>";
$str .= "</table>";

echo $str;

PM me if you need more help.

umm.. are you looking for some resource on how to write such authentication script for php? how much is your php programming experience? Depending on that there are different examples online. You may google it with PHP authentication or something similar.

i use this code for most of my html in the sites i have developed:

$html =<<<HTML
any html content contained here
HTML;

Thanks all. I will try to utilize all all above.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.