Jump to content

include php file in table = header already sent


makenoiz

Recommended Posts

FYI: I did read the sticky about headers and I still need help.. thanks....Im not sure of a way around this. I have an index.php file. In that file I have html code: a table and in the table 2 includes  to pull in to php files. I get the wonderful headers already sent error.

 

How can I get around this? Should i just use evil Iframes?

 

heeeeeeelllppp

 

thanks

makenoiz

Thanks for your lightning fast reply - wow!  Just so you know, I do understand that Im not allowed to send html content to browser before sending php processing. Im just not sure of a way around....

 

 

Here is my basic little code.

 

<?php

session_start();

echo ' <div align="center">

  <p><img src=" /images/header.png" width="800" height="168" /></p>

  <table width="800" border="1" cellspacing="0" cellpadding="15">

    <tr>

      <td width="380" valign="top" scope="row"><img src="/images/find.gif" width="178" height="40" /></td>

      <td width="13">';

    include "search.php";

 

  echo '</td>

      <td width="387" valign="top"><img src="/images/edit.gif" width="178" height="40" /></td>

    </tr>

    <tr><td valign="top" scope="row"> </td>

      <td><img src="/images/divider.gif" width="11" height="245" /></td>

      <td valign="top">';

  include "login.php";

 

echo ' </td> </tr>

    <tr>

      <td colspan="3" valign="top" scope="row"><div align="center">Registration is always FREE! </div></td>

    </tr>

  </table>

  <p></p></div>';

 

?>

search.php

.......

//begin search.php

<?php

echo 'Search goes here';

?>

 

//end search.php

 

 

login.php

..........

 

//begin login.php

<?php

session_start();

include 'var/obuf.inc.php';// ## db vars 

if(isset($_POST['login']))

{

 

$username = trim(addslashes($_POST['username']));

$password = md5(trim($_POST['password']));

 

$query = mysql_query("SELECT * FROM Users WHERE Username = '$username' AND Password = '$password' LIMIT 1") or die(mysql_error());

 

$row = mysql_fetch_array($query);

 

// now we check if they are activated

 

if(mysql_num_rows($query) > 0)

{

 

if($row['Activated'] > 0)

{

 

$_SESSION['s_logged_n'] = 'true';

$_SESSION['s_username'] = $username;

$_SESSION['s_name'] = $row['Name'];

 

header("Location: member.php");

 

} else {

 

echo '

<html>

<head>

<title>Login</title>

<link href="style.css" rel="stylesheet" type="text/css">

 

</head>

 

<body>

<div id="error"><p>Sorry, you must activate your account first. Please check your email for the email.</p>

<p>Didn'."'".'t get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p></div>

</body>

</html>

';

 

}

 

} else {

 

echo '

<html>

<head>

<title>Login</title>

<link href="style.css" rel="stylesheet" type="text/css">

</head>

 

<body>

<div id="error"><p>There was an error processing your login, it appears that your username and/or password was incorrect. Please try again.</p>

  <p>Didn'."'".'t get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p>

 

</div>

</body>

</html>

';

 

}

 

} else {

?>

<html>

<head>

<title>Login</title>

<link href="style.css" rel="stylesheet" type="text/css">

</head>

 

<body>

 

<div id="wrapper">

 

<!-- <div id="head">the login page</div><br>-->

<div id="main">

  <p>You must login to view this page. Enter your username and password below and hit submit:</p>

  <form method="post" action="<?= $_SERVER['PHP_SELF'] ?>">

  <p>Username:<br>

  <input name="username" type="text" class="textBox" id="username">

 

  <p>Password:<br>

    <input name="password" type="password" class="textBox" id="password">

</p>

  <p>

    <input name="login" type="submit" class="textBox" id="login" value="Submit">

  </p>

  </form>

  <p>Didn't get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p>

  <p>Need an account? <a href="register.php">Click here</a> to register, it's completely free! </p>

</div>

 

</div>

 

</body>

</html>

<? } mysql_close($l); ?>

 

//end login.php

 

 

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.