And now i'm doing some things diffrent. If they go to profile.php an headers come and they get redirected to profile.php?=_username_
But I get some errors now that i can't get away, don't know why i get them though. Seems correct for me.
Notice: Undefined variable: age in /srv/www/htdocs/profile2.php on line 46
Notice: Undefined offset: 2 in /srv/www/htdocs/profile2.php on line 23
Notice: Undefined offset: 1 in /srv/www/htdocs/profile2.php on line 23
Code: Select all
<?php
session_start(); // Alltid överst på sidan
error_reporting(E_ALL);
include "configs.php"; // Databasanslutningen
// Kolla om inloggad = sessionen satt
if (!isset($_SESSION['sess_user'])) {
header("Location: index.php");
exit;
}
?>
<?php
$person = substr($_SERVER['QUERY_STRING'], 1);
if($person == $_SESSION['sess_user']) {
$person2 = $_SESSION['sess_user'];
$sql2 = "SELECT * FROM members WHERE username = '{$_SESSION['sess_user']}'";
$result2 = mysql_query($sql2) or die(mysql_error());
function birthday ($age){
// assumes $birthdate is in YYYY-MM-DD format
list($dob_year, $dob_month, $dob_day) = explode('-', $age);
// determine current year, month, and day
$cur_year = date('Y');
$cur_month = date('m');
$cur_day = date('d');
// either past or on the birthday
if($cur_month >= $dob_month && $cur_day >= $dob_day) {
$age1 = $cur_year - $dob_year;
}
// before the birthday
else {
$age1 = $cur_year - $dob_year;
}
// and your done
return $age1;
}
$content = "<table>";
while($rad = mysql_fetch_array($result2))
{
$header = $person2;
$header .= " ";
$header .= $rad['sex'];
$header .= birthday($age);
$age = $rad['age'];
$kon = $rad['sex'];
$content .= "<tr>";
$content .= "<td>";
$content .= "<br>";
if(empty($rad['picture']))
{
$content .= "<img src='images/inget-foto.jpg' width='50' height='50'>";
}
else
{
$content .= "<img src='images/". $rad['picture']."'>";
}
$content .= "<br>";
$content .= "</td></tr>";
$content .= "<tr>";
$content .= "<td width=220><b>Användarnamn: </b>".$rad['username']." </td><td width=20></td><td width=125><b>Civilstånd:</b> </td><td>".$rad['civil']."</td>";
$content .= "</tr>";
$content .= "<tr>";
$content .= "<td width=220><b>Län:</b> ".$rad['lan']."</td><td width=20></td><td width=125><b>Sexuell läggning:</b></td><td>".$rad['sexuel']."</td>";
$content .= "</tr>";
$content .= "<tr>";
$content .= "<td width=220><b>Längd:</b> ".$rad['height']."</td><td width=20></td><td width=125><b>Vikt:</b></td><td>".$rad['weight']."</td>";
$content .= "</tr>";
$content .= "<tr>";
$content .= "<td width=220><b>Ögonfärg:</b> ".$rad['eye_color']."</td><td width=20></td><td width=125><b>Hårfärg:</b></td><td>".$rad['hair_color']."</td>";
$content .= "</tr>";
$content .= "</table>";
$content .= "<table>";
$content .= "<td><br><br></td>";
$content .= "<td width=100><b>Gästbok</b></td><td width=100><b>Film Galleri</b></td><td width=100><b>Bild Galleri</b></td><td width=100><b>Gör favorit</b></td><td width=100><b>Blog</b></td>";
$content .= "</tr>";
$content .= "</table>";
}