Session problem (2)
Hej. Jeg har fået endnu et problem med mine sessions, sidst jeg havde var der fordi kørte script på index.php derfor satte session_start();, i toppen af dette, men nu er jeg købet ind i et andet problem, at den kun henter halvdelen af min index.php når jeg kører dette script i min "main"....<?php
session_start();
if (!session_is_registered("username")) {
echo "<p>Du skal være logget ind!</p>";
die;
}
else {
}
include("dbconn.php");
$result1=mysql_query("select * from users WHERE username='$username'") or die ("cant do it");
$row100 = mysql_fetch_array($result1);
?>
<p>| <a href="mail.php?action=compose">Compose</a> | <a href="mail.php?action=inbox">Inbox</a>
| </p>
<p><br />
<a href=login_success.php><--back</a><table cellpadding="1" cellspacing="1" height="300" width="450">
</p>
<tr><td align=center valign=top>
<?php
if($action==compose) {
echo "<form action=mail.php?action=compose2 method=post>";
echo "<table>";
echo "<tr><td>Subject:</td><td><input type=text name=subject size=20 value=$subject></td></tr>";
echo "<tr><td>To:</td><td><input type=text name=to size=20 value=$to></td></tr>";
echo "<tr><td>Message:</td><td><textarea rows=16 cols=45 name=message></textarea></td></tr>";
echo "<tr><td><input type=submit value=post></td></tr>";
echo "</table>";
echo "</form>";
}
if($action==compose2) {
$subject or die("Subject Blank");
$message or die("Message Black");
$to or die("To blank");
$date = date(YmdHis);
$create = "INSERT INTO mail (UserTo, UserFrom, Subject, Message, SentDate, status)
VALUES ('$to','$username','$subject','$message','$date','unread')";
$create2 = mysql_query($create) or die("A letter could not be sent to $to!");
echo("Message Sent to $to!");
}
if($action==inbox) {
$result=mysql_query("select * from mail where UserTo='$username' ORDER BY SentDate DESC") or die ("cant do it");
echo "<table cellpadding=2 cellspacing=1 width=500 valign=top>";
while ($row=mysql_fetch_array($result)) {
echo "<tr><td width=30>Mail:</td><td><a href=mail.php?action=veiw&mail_id=$row[mail_id]>$row[Subject]</a></td><td width=50> <a href=mail.php?action=delete&id=$row[mail_id]><center>Delete</a><br></td></tr>";
}
echo "</table>";
}
if($action==veiw) {
$result=mysql_query("select * from mail where UserTo='$username' and mail_id=$mail_id") or die ("cant do it");
$row=mysql_fetch_array($result);
if($row[UserTo]==$username) {
} else {
echo "<font face=verdana><b>This isn't your mail!";
exit;
}
$query="UPDATE mail SET status='read' WHERE UserTo='$username' AND mail_id='$row[mail_id]'";
$query or die("An error occurred resulting that this message has not been marked read.");
echo "<table border = 1 bordercolor = black width = 50% align=center><tr><td>$row[Subject]</td><td>$row[UserFrom]</td></tr><tr><td colspan='2'>$row[Message]<br><a href=mail.php?action=compose&to=$row[UserFrom]&subject=RE:$row[Subject]>Reply</a></td></tr></table>";
$rs = mysql_query("UPDATE mail SET status='read' WHERE mail_id='$mail_id'");
}
if($action==delete) {
$query = mysql_query("DELETE FROM mail WHERE mail_id='$id' LIMIT 1");
if($query) {
echo "<font face=verdana>Message Deleted.</font>";
} else {
echo "The message wasnt deleted.";
}
}
?>
håber at der er en som kan hjælpe :D
