[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Include a file with html formating

Posted on 2007-10-18
7
Medium Priority
?
183 Views
Last Modified: 2007-10-18
I am trying to include a file that has html formating but when I include this to my main php file, it doesn't show any records. What am I doing wrong. Here is the file
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
<?php

// Start the login session
session_start();

if (!$_SESSION['user'] || !$_SESSION['pass']) {

// What to do if the user hasn't logged in
// We'll just redirect them to the login page.
header('Location: login.php');
die();

} else {





 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style3 {font-size: large}
-->
</style>
</head>

<body>
<table width="200" border="2" bordercolor="#80B2E2">
  <tr>
    <td><h1 class="style3">Cose 1</h1></td>
  </tr>
  <tr>
    <td><h1 class="style3">Born 3</h1></td>
  </tr>
  <tr>
    <td><span class="style3">Font 1</span></td>
  </tr>
  <tr>
    <td><span class="style3">Front 21</span></td>
  </tr>
  <tr>
    <td><span class="style3">Prk 16</span></td>
  </tr>
  <tr>
    <td><span class="style3">latte 1</span></td>
  </tr>
  <tr>
    <td><span class="style3">Setwater 1</span></td>
  </tr>
  <tr>
    <td><span class="style3">inta 1</span></td>
  </tr>
  <tr>
    <td><span class="style3">6</span></td>
  </tr>
</table>
</body>
</html>
?>
Thanks
0
Comment
Question by:syedasimmeesaq
  • 3
  • 2
  • 2
7 Comments
 
LVL 17

Expert Comment

by:nplib
ID: 20103854
you can't have html inbetween <?php ?> tags
if you want it to show you have to surround all your html lines with
echo "<html>';

if there are any parts that have " in them then you have to do it like this
echo "<td><span class=\"style3\">6</span></td>"

or place all of your html in a variable and echo that variable at the end.
$html = "<html>";
$html .= "</html>";

echo $html;
0
 
LVL 21

Accepted Solution

by:
nizsmo earned 2000 total points
ID: 20103892
Correct code with a little modification. You also forgot the closing brackets for the else:


<?php

// Start the login session
session_start();

if (!$_SESSION['user'] || !$_SESSION['pass']) {

// What to do if the user hasn't logged in
// We'll just redirect them to the login page.
header('Location: login.php');
die();

} else {
?>




 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style3 {font-size: large}
-->
</style>
</head>

<body>
<table width="200" border="2" bordercolor="#80B2E2">
  <tr>
    <td><h1 class="style3">Cose 1</h1></td>
  </tr>
  <tr>
    <td><h1 class="style3">Born 3</h1></td>
  </tr>
  <tr>
    <td><span class="style3">Font 1</span></td>
  </tr>
  <tr>
    <td><span class="style3">Front 21</span></td>
  </tr>
  <tr>
    <td><span class="style3">Prk 16</span></td>
  </tr>
  <tr>
    <td><span class="style3">latte 1</span></td>
  </tr>
  <tr>
    <td><span class="style3">Setwater 1</span></td>
  </tr>
  <tr>
    <td><span class="style3">inta 1</span></td>
  </tr>
  <tr>
    <td><span class="style3">6</span></td>
  </tr>
</table>
</body>
</html>
<?php
}
?>
0
 
LVL 9

Author Comment

by:syedasimmeesaq
ID: 20103900
I tried this but this didn't work either

<?php

// Start the login session
session_start();

if (!$_SESSION['user'] || !$_SESSION['pass']) {

// What to do if the user hasn't logged in
// We'll just redirect them to the login page.
header('Location: login.php');
die();

} else {





 
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
echo "<head>";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
echo "<title>Untitled Document</title>";
echo "<style type=\"text/css\">";

echo "</head>";

echo "<body>";
echo "<table width=\"200\" border=\"2\" bordercolor=\"#80B2E2\">";
echo  "<tr>";
echo    "<td><h1 class=\"style3\">Conse 1</h1></td>";
echo  "</tr>";
echo  "<tr>";
echo "</body></htm>";

?>

XXXXXXXXXXXXXXXXXXXXXXXXXX

what I am trying to do is to see if the user is loggec in and then show this table

Thanks
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 17

Expert Comment

by:nplib
ID: 20103902
darn you I was getting to that.
0
 
LVL 17

Expert Comment

by:nplib
ID: 20103916
you style tag isn't closed, that will prevent HTML from showing.
0
 
LVL 9

Author Comment

by:syedasimmeesaq
ID: 20103918
nizsmo: home run  :-)

That worked

Thanks a lot
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20103922
Glad to be of assistance :)
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month20 days, 3 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question