MySQL Forums
Forum List  »  PHP

Sessions refusing to work PLEASE HELP PLEASE
Posted by: terry tatenda
Date: November 01, 2012 03:36PM

SORRY FOR THE CAPITAL LETTERS!!! THIS IS THE CODE FOR MY LOGIN PAGE THE CODE FOR THE PROFILE PAGE IS BELOW AFTER THE LOFING PAGE CODE. THE ERROR IM GETTING ON MY PROFILE PAGE AFTER I LOGIN IS :---Notice: Undefined index: id in C:\wamp\www\project\profile.php on line 22
AND--- mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\project\profile.php on line 127
AND--- Undefined variable: sign_up_date in C:\wamp\www\project\profile.php on line 172

SEEMS LIKE MY SESSIONS ARE NOT WORKING OR IM CODING THIS WRONG. I'LL GLADLY PROVIDE MORE INFORMATION IF IT IS NEEDED


<?php

session_start();
if (isset($_SESSION["email"])) {
header("location: profile.php");
exit();
}
?>
<?php
if (isset($_POST["email"]) && isset($_POST["password"])) {

$email = $_POST["email"];
$password = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["password"]);
include "scripts/connect_to_mysql.php";
//$password = md5($password);
$sql = mysql_query("SELECT id FROM myMembers WHERE email='$email' AND password='$password' LIMIT 1");
$existCount = mysql_num_rows($sql);
if ($existCount == 1) {
while($row = mysql_fetch_array($sql)){
$id = $row["id"];

//$_SESSION["id"] = $id;
// $_SESSION["manager"] = $manager;
//$_SESSION["password"] = $password;


$id = $row["id"];
session_register('id');
$_SESSION['id'] = $id;

$firstname = $row["firstname"];
session_register('firstname');
$_SESSION['firstname'] = $firstname;

$email = $row["email"];
session_register('email');
$_SESSION['email'] = $email;



header("location: profile.php");
mysql_query("UPDATE myMembers SET last_log_date=now() WHERE id='$id'");
exit();
}
} else {
echo 'That information is incorrect, try again <a href="login.php">Click Here</a>';
exit();
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">;
<html xmlns="http://www.w3.org/1999/xhtml">;
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>User Log In </title>
<link rel="stylesheet" href="../style/style.css" type="text/css" media="screen" />
</head>

<body>
<div align="center" id="mainWrapper">
<?php include_once("header_template.php");?>
<div id="pageContent" width="80%"><br />
<div align="left" style="margin- left:24px;">
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<h2 align="left"> Login To The House of Terry</h2>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
<form id="form1" name="form1" method="post" action="login.php">

<div align="left">
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<p>Email-Add:<br />
<input name="email" type="text" id="email" size="40" />
<br />
<br />
Password:<br />
<input name="password" type="password" id="password" size="40" />
<br />
<br />
<br />

<input type="submit" name="button" id="button" value="Log In" />
</p>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</div>
</form>
<p>&nbsp; </p>
</div>
<br />
<br />
<br />
</div>
<?php include_once("footer_template.php");?>
</div>
</body>
</html>



THIS IS THE PROFILE PAGE IM TRYING TO USE



<?php
session_start();


include_once "scripts/connect_to_mysql.php";

$id = "";
$firstname = "";
$middlename = "";
$lastname = "";
$country = "";
$state = "";
$city = "";
$zip = "";
$bio_body = "";
$bio_body = "";
$website = "";
$youtube = "";
$user_pic = "";
$blabberDisplayList = "";

if ($_GET['id']) {

$id = $_GET['id'];

} else if (isset($_SESSION['id'])) {

$id = $_SESSION['id'];

} else {

include_once "index.php";
exit();
}
$id = mysql_real_escape_string($id);
$id = eregi_replace("`", "", $id);
$sql = mysql_query("SELECT * FROM myMembers WHERE id='$id'");

while($row = mysql_fetch_array($sql)){

$firstname = $row["firstname"];
$lastname = $row["lastname"];
$country = $row["country"];
$state = $row["state"];
$city = $row["city"];
$zip = $row["zip"];
$email = $row["email"];
$sign_up_date = $row["sign_up_date"];
$sign_up_date = strftime("%b %d, %Y", strtotime($sign_up_date));
$last_log_date = $row["last_log_date"];
$last_log_date = strftime("%b %d, %Y", strtotime($last_log_date));
$bio_body = $row["bio_body"];
$website = $row["website"];
$youtube = $row["youtube"];
$check_pic = "members/$id/image01.jpg";
$default_pic = "members/0/image01.jpg";
if (file_exists($check_pic)) {
$user_pic = "<img src=\"$check_pic\" width=\"300px\" />";
} else {
$user_pic = "<img src=\"$default_pic\" width=\"300px\" />";
}
if ($youtube == "") {
$youtubeChannel = "<br />This user has no YouTube channel yet.";
} else {
$youtubeChannel = ' <script src="http://www.gmodules.com/ig/ifr?url=http://www.google.com/ig/modules/youtube.xml&amp;up_channel='; . $youtube . '&amp;synd=open&amp;w=290&amp;h=370&amp;title=&amp;border=%23ffffff%7C3px%2C1px+solid+%23999999&amp;output=js"></script> ';
}

}
$style_sheet = "default";
?>
<?php
$blab_outout_msg = "";
if ($_POST['blab_field'] != ""){

$sqlDeleteBlabs = mysql_query("SELECT * FROM blabbing WHERE mem_id='$id' ORDER BY blab_date DESC LIMIT 50");

$bi = 1;

while ($row = mysql_fetch_array($sqlDeleteBlabs)) {

$blad_id = $row["id"];
if ($bi > 20) {

$deleteBlabs = mysql_query("DELETE FROM blabbing WHERE id='$blad_id'");
}
$bi++;
}

$blab_field = $_POST['blab_field'];
$blab_field = stripslashes($blab_field);
$blab_field = strip_tags($blab_field);
$blab_field = mysql_real_escape_string($blab_field);
$blab_field = eregi_replace("'", "&#39;", $blab_field);

$sql = mysql_query("INSERT INTO blabbing (mem_id, the_blab, blab_date)
VALUES('$id','$blab_field', now())")
or die (mysql_error());

$blab_outout_msg = "Your Blab has been posted!";
}

?>




<?php
$the_blab_form = "";
if (isset($_SESSION['id'])) {

if ($_SESSION['id'] == $id){
$the_blab_form = '
' . $blab_outout_msg . '

<form action="profile.php" method="post" enctype="multipart/form-data" name="blab_from">
<textarea name="blab_field" rows="3" style="width:97%;"></textarea>
Blab away (220 char max) <input name="submit" type="submit" value="submit" />
</form>';
}
}

?>

<?php
$sql_blabs = mysql_query("SELECT id, mem_id, the_blab, blab_date FROM blabbing WHERE mem_id='$id' ORDER BY blab_date DESC LIMIT 20");

while($row = mysql_fetch_array($sql_blabs)){

$blabid = $row["id"];
$uid = $row["mem_id"];
$the_blab = $row["the_blab"];
$blab_date = $row["blab_date"];
$blab_date = strftime("%b %d, %Y, %Y %I:%M:%S %p", strtotime($blab_date));

$blabberDisplayList .= '
<table width="100%" align="center" cellpadding="4" bgcolor="#A6D2FF">
<tr>
<td width="93%" bgcolor="#D9ECFF"><span style="font-size:10px; font-weight:bold; color:#A6A6A6;">' . $blab_date . '</span><br />
' . $the_blab . '</td>
</tr>
</table>';

}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">;
<html xmlns="http://www.w3.org/1999/xhtml">;
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="Description" content="Profile for <?php print "$firstname $lastname"; ?>" />
<meta name="Keywords" content="<?php print "$firstname, $lastname, $city, $state, $country"; ?>" />
<meta name="rating" content="General" />
<meta name="ROBOTS" content="All" />
<title>Site Profile for <?php print "$firstname $lastname"; ?></title>
<link href="style_profiles/<?php print "$style_sheet"; ?>.css" rel="stylesheet" type="text/css" />
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
</head>

<body>
<?php include_once "header_template.php"; ?>
<table width="950" align="center">
<tr>
<td width="758"><br />
<table width="90%" border="0" align="center" cellpadding="6">
<tr>
<td width="48%" valign="top">
<?php print "$firstname $lastname"; ?>
<br />
<?php print "$user_pic"; ?>
<br />
Member Since: <?php print "$sign_up_date"; ?>
<br />
<?php print "$youtube"; ?>
</td>
<td width="52%" valign="top">
<br />
<strong><u><?php print "$firstname $lastname"; ?>'s Blabs:</u></strong>
<br />
<?php print "$the_blab_form"; ?>
<div style="width:100%; height:180px; overflow:auto; overflow-x:hidden;">
<?php print "$blabberDisplayList"; ?>
</div>
<br />
<br />
<strong><u><?php print "$firstname $lastname"; ?>'s Location Details:</u></strong>
<br />
<?php print "$city"; ?> &bull; <?php print "$state"; ?> &bull; <?php print "$country"; ?>
<br />
<br />
<strong><u>About <?php print "$firstname $lastname"; ?></u></strong>
<br />
<?php print "$bio_body"; ?>
<br />


</td>
</tr>
<tr>
<td colspan="2" valign="top">&nbsp;</td>
</tr>
</table>
<p><br />
<br />
</p>
<p>&nbsp;</p>
<p><br />
<br />
<br />
<br />
<br />
</p></td>
<td width="180" valign="top"><?php include_once "rightAD_template.php"; ?></td>
</tr>
</table>
<?php include_once "footer_template.php"; ?>
</body>
</html>

Options: ReplyQuote


Subject
Written By
Posted
Sessions refusing to work PLEASE HELP PLEASE
November 01, 2012 03:36PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.