soompi forums: Php Help! - soompi forums

Jump to content

Page 1 of 1

Php Help!

#1 User is offline   emma_fifth 

  • Member
  • Pip
  • Group: Members
  • Posts: 796
  • Joined: 02-June 07

Posted 26 November 2008 - 03:10 PM

this language is driving me crazy crazy.gif


okay, so my problem is...i create a login form, then i include it in the main page. when i run it without the main page, it is okay. but when i run it through the main page, it shows me

QUOTE
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\SPA_PURPLE\index.php:18) in C:\xampp\htdocs\SPA_PURPLE\index.php on line 106


can someone help me with this?
0

#2 User is offline   awdark 

  • Cookie Monster
  • Icon
  • Group: Administrators
  • Posts: 9,591
  • Joined: 04-October 05

Posted 26 November 2008 - 03:49 PM

I don't know php but you will need to include the index.php for us to look at.

Line 18 or 106 has issues so hopefully someone can take a look and figure out whats wrong.
0

#3 User is offline   emma_fifth 

  • Member
  • Pip
  • Group: Members
  • Posts: 796
  • Joined: 02-June 07

Posted 26 November 2008 - 04:47 PM

QUOTE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="style.css" />
<title>Diva Spa :: Your Escape To Beauty</title>
<style type="text/css">
<!--
.style3 {font-size: x-small}
.style4 {
color: #FFFFFF;
font-size: 10px;
}
.style5 {font-size: 10px}
.style6 {
font-size: 12px;
color: #FFFFFF;
font-family: Arial, Helvetica, sans-serif;
}
.style7 {font-family: Arial, Helvetica, sans-serif}
-->
</style>
</head>



<body>

<div id="container">

<div id="header"></div>

<div id="navcontainer">
<ul id="navlist">
<li id="active"><a href="index.html" id="current">Home</a></li>
<li><a href="services.php"> Services</a></li>
<li><a href="specialoffers.php">Special Offers</a></li>
<li><a href="reservations.php">Reservation</a></li>
<li><a href="aboutus.php">About Us</a></li>
</ul>
</div>

<div id="wrapper">

<div id="left">
<ul class="list">
<li><a href="#">vertical links</a></li>
<li><a href="#">vertical links</a></li>
<li><a href="#">vertical links</a></li>
<li><a href="#">vertical linksr</a></li>
</ul>
</div>


<div id="right">
<p><?php
// Connects to your Database
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("spa") or die(mysql_error());

//checks cookies to make sure they are logged in
if(isset($_COOKIE['ID_my_site']))
{
$username = $_COOKIE['ID_my_site'];
$pass = $_COOKIE['Key_my_site'];
$check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());
while($info = mysql_fetch_array( $check ))
{

//if the cookie has the wrong password, they are taken to the login page
if ($pass != $info['password'])
{ header("Location: login.php");
}

//otherwise they are shown the admin area
else
{
echo "Admin Area<p>";
echo "Your Content<p>";
echo "<a href=logout.php>Logout</a>";
}
}
}
else

//if the cookie does not exist, they are taken to the login screen
{
header("Location: login.php");
}
?>

</p>
</div>

<div id="content">

<h1>Special Offer For December</h1>
<p><script src="flashLoad.js" type="text/javascript"></script>
<script>loadFlash("specialoffer.swf", 400, 100, "swf/")</script></p>
See the details on <a href="specialoffers.php">Special Offers

</a>
<h2>Reservations Available</h2>
<p>We have added Reservation Menu for you, our loyal customers. Easier and faster booking to your beauty! Registered as a member is required. Click here to Register or <a href="reservations.php">Reserve</a> your place now!<br />
As always, your suggestions and feedbacks are highly appreciated for our future development.</p>
</div>
</div>
</div>
<p align="center"><span class="style3"><span class="style5"><span class="style6"><strong>Hours of Operation:</strong><br />
Monday through Friday from 10am-6pm |
Saturdays by Appointment<br />
Diva Spa: 1403 W. 47th St.
<strong>Phone: </strong>512-420-8106 </span></span></span>
</p>
</p>
<p align="center" class="style4"><span class="style7">Home | Services | Special Offers | Reservations | About Us<br />
<strong>Content: &copy; 2008 Diva Spa: All Rights Reserved </strong></span></p>
</body>
</html>


this is the whole index page.
is there something wrong with the cookie?
0

#4 User is offline   Donnerschlag 

  • Member
  • Pip
  • Group: Members
  • Posts: 324
  • Joined: 23-November 08

Posted 30 November 2008 - 08:15 PM

QUOTE (emma_fifth @ Nov 26 2008, 04:10 PM) <{POST_SNAPBACK}>
this language is driving me crazy crazy.gif

okay, so my problem is...i create a login form, then i include it in the main page. when i run it without the main page, it is okay. but when i run it through the main page, it shows me

can someone help me with this?



CODE
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\SPA_PURPLE\index.php:18) in C:\xampp\htdocs\SPA_PURPLE\index.php on line 106


The "Cannot modify header information - headers already sent" error is usually caused by having whitespace before/after the opening and closing PHP tags.

Try removing the whitespaces before or after the <?php and ?>.
www.OnciuHungry.com - Easy to make food for the everyday college student!
www.azkseries.com - Arizona Car Enthusiasts
0

#5 User is offline   dot1q 

  • The Mysterious One
  • Icon
  • Group: Friends of Soompi
  • Posts: 2,704
  • Joined: 04-October 05

Posted 02 December 2008 - 08:59 AM

The error is exactly what it states. You are trying to send header information ({ header("Location: login.php")wink.gif after it has already been sent. You have regular html code which starts off the code which by nature will send header information out. You can't send header information with php after any data has been sent to the client. This means you can't have any native html code, use print, use echo, etc preceding a header function in your code. The reason why it works without the main body is because you haven't sent any data to the client yet and the header function is the first output to the client. The best workaround is to either encapsulate your html code within a php variable and echo out the output at the end of your process OR use php output buffering (google it). Either way, the main point being, the output from the header function needs to be the FIRST thing sent to the client. No other information can precede it.

The guy above me is right but for the same reason I state. The blank space is being sent before the header information. It's still alone not going to help your case those though. This is mostly the case when people think they're doing it right but didn't realize and empty space before the <?php. But at least you know why now. smile.gif

Good luck.
:)
0

#6 User is offline   Raix 

  • Member
  • Pip
  • Group: Members
  • Posts: 3,741
  • Joined: 04-October 05

Posted 03 December 2008 - 10:40 PM

Easiest fix, use a meta redirect tag instead of a header redirect. it's html and not instant but it does the job.
MATHMATICIOUS.
0

Share this topic:


Page 1 of 1

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users