PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?
include("include/activity.php");
?>
<html>
<title>Room Booking</title>
<body>
<?
/**
* User has submitted form without errors and user's
*/
if(isset($_activity['useredit'])){
unset($_activity['useredit']);
echo "<h1>Room Booking Success!</h1>";
echo "<p><b>$activity->username</b>, Booking done. "
."<a href=\"main.php\">Main</a>.</p>";
}
else{
?>
<?
/**
* If user is not logged in, then do not display anything.
*/
if($activity->logged_in){
if(isset($_activity['bookingSuccess'])){
/* Registration was successful */
if($_activity['bookingSuccess']){
echo "<h1>Booked</h1>";
echo "<p>Thanks!".$_activity['bookingName']."</b>, your booking is now part of the system! "
."Click here <a href=\"main.php\">to go back</a>.</p>";
}
/* Registration failed */
else{
echo "<h1>Failed to Book</h1>";
echo "<p>Theres been a error for that roomname<b>".$_activity['bookingName']."</b>, "
."could not be completed.<br>Please try again at a later time.</p>";
}
unset($_activity['bookingSuccess']);
unset($_activity['bookingName']);
}
?>
<h1>Room Booking in name of: <? echo $activity->username; ?></h1>
<form action="process.php" method="POST">
Room Name : <input name="roomName" type="text"><br>
<input name="send" type="submit" value="Submit">
</form>
<?
}
?>
</body>
</html>
<?php include("include/activity.php"); ?>
<html>
<title>Room Booking</title>
<body>
<?php
/**
* User has submitted form without errors and user's
*/
if (isset($_activity['useredit'])) {
unset($_activity['useredit']);
echo "<h1>Room Booking Success!</h1>";
echo "<p><b>$activity->username</b>, Booking done. "
. "<a href=\"main.php\">Main</a>.</p>";
} else {
/**
* If user is not logged in, then do not display anything.
*/
if ($activity->logged_in) {
if (isset($_activity['bookingSuccess'])) {
/* Registration was successful */
if ($_activity['bookingSuccess']) {
echo "<h1>Booked</h1>";
echo "<p>Thanks!".$_activity['bookingName']."</b>, your booking is now part of the system! "
."Click here <a href=\"main.php\">to go back</a>.</p>";
} else {
echo "<h1>Failed to Book</h1>";
echo "<p>Theres been a error for that roomname<b>".$_activity['bookingName']."</b>, "
."could not be completed.<br>Please try again at a later time.</p>";
}
unset($_activity['bookingSuccess']);
unset($_activity['bookingName']);
}
?>
<h1>Room Booking in name of: <?php echo $activity->username; ?></h1>
<form action="process.php" method="POST">
Room Name : <input name="roomName" type="text"><br>
<input name="send" type="submit" value="Submit">
</form>
<?php
}
}
?>
</body>
</html>
# <?
# /**
# * User has submitted form without errors and user's
# */
# if(isset($_activity['useredit'])){
# unset($_activity['useredit']);
#
# echo "<h1>Room Booking Success!</h1>";
# echo "<p><b>$activity->username</b>, Booking done. "
# ."<a href=\"main.php\">Main</a>.</p>";
# }
# else{
# ?>
As I don't think I actually need that.
While were on this subject any idea why i am also getting a:
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/grads/public_html/computing_project/login5/bookingtest.php:2) in /home/grads/public_html/computing_project/login5/include/activity.php on line 45
?
Heres the function related to line 45 activity.php
function activityStart(){
global $database; //The database connection
session_start(); //Tell PHP to start the session
/* Determine if user is logged in */
$this->logged_in = $this->check();
/**
* Set guest value to users not logged in, and update
* active guests table accordingly.
*/
if(!$this->logged_in){
$this->username = $_SESSION['username'] = gs_name;
$this->userlevel = gs_level;
$database->addActiveGuest($_SERVER['REMOTE_ADDR'], $this->time);
}
/* Update users last active timestamp */
else{
$database->addActiveUser($this->username, $this->time);
}
/* Remove inactive visitors from database */
$database->removeInactiveUsers();
$database->removeInactiveGuests();
/* Set referrer page */
if(isset($_SESSION['url'])){
$this->referrer = $_SESSION['url'];
}else{
$this->referrer = "/";
}
/* Set current url */
$this->url = $_SESSION['url'] = $_SERVER['PHP_SELF'];
}
astions wrote:You cannot start a session after you have sent output.
Right ok, so forgive my stupidity, but whats the difference with me doing a page like this? Except in this case my signup page only works if the user is not logged in.
There is a new line character on line one. That counts as output. Assuming you are calling session_start() in activity.php, and there is no output being sent in activity.php, that new line character would be your problem.
astions wrote:There is a new line character on line one. That counts as output. Assuming you are calling session_start() in activity.php, and there is no output being sent in activity.php, that new line character would be your problem.