problem with SESSION
Posted: Fri May 25, 2007 6:01 pm
Hi every one I used SESSION in my code to let the user update his file it is a simple code it work but it show me a warning I don't know why so please help me to solve this problem
form code
this is printscreen for it
http://www.arbwb.com/img/download.php?f ... c76b9ea781
action code
this is printscreen for it
http://www.arbwb.com/img/download.php?f ... e6979afe6b
so help me [s]plzzzzzzzzzzzzz[/s] please

form code
Code: Select all
<?php
session_start();
if(!isset($_SESSION['loggedin'])) {
print'<p align="right"><font size=4 face=AGA Dimnah Regular color=#DAB936> <b> your not register </font></b>
<br /> <a href="register.php"> register </a></p>';
exit(); }
?>
<html>
<style type="text/css">
body {
<?php
// Address error handing.
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);
// Check for a bg_color value.
if (isset ($_COOKIE['bg_color'])) {
print "\t\tbackground-color: {$_COOKIE['bg_color']};\n";
} else {
print "\t\tbackground-color: #ffffff;\n";
}
?>
}
</style>
<head>
<title>update page</title>
<!--favorite-->
<SCRIPT language="JavaScript1.2">
var bookmarkurl="http://localhost/finalproject/index.php";
var bookmarktitle="cook site";
function addbookmark(){
if (document.all)
window.external.AddFavorite(bookmarkurl,bookmarktitle);
}
</SCRIPT>
<!--end-favorite-->
</head>
<body>
<table border="0" width="100%" id="table1" height="578" cellspacing="0" cellpadding="0">
<tr>
<td height="1" colspan="2">
<p>
</td>
</tr>
<tr>
<td height="1" colspan="2">
<p dir="rtl" align="center">
</td>
</tr>
<tr>
<td height="127" width="83%">
<p dir="rtl">
</td>
<td height="127" width="17%" background="image/43.gif">
<?php
if(isset($_SESSION['loggedin'])){
print '
<p align="center"><font size=3 face=AGA Dimnah Regular color=#826C51> <b> Hi <br/> ** ' .$_SESSION['loggedin'] . ' ** </font></b>
<br /></p>'; }?>
</td>
</tr>
<tr>
<td width="100%" background="image/35.gif" rowspan="2" colspan="2">
<div style="position: absolute; width: 552px; height: 483px; z-index: 1; left: 212px; top: 172px" id="layer1">
<?php
$dbc = @mysql_connect ('localhost','root','');
$db_selected = mysql_select_db('recipes_club', $dbc);
mysql_query("set charset cp1256");
$result = mysql_query("SELECT * FROM user ", $dbc);
$num_rows = mysql_num_rows($result);
echo '<div align="center"><p>';
$name=$_SESSION['loggedin'];
$query = "SELECT * FROM user WHERE name ='$name'";
if ($r = mysql_query ($query)) { // Run the query.
$row = mysql_fetch_array ($r); // Retrieve the information.
// Make the form.
print"<form action='p1.php' method='post'>";
print"<div align="center"><table cellspacing="0" cellpadding="0">";
print"<font face="AGA Dimnah Regular" color=#E3D1AC size=6 >to update your profile {$row['name']}</font><br /><br />";
print'<br><font face="AGA Aladdin Regular" color="#C8A459" size=5><P><br /></font>';
print'<font face="AL-Hor" size="5" color="#AC8959" align=rigth> password </font><input type="password" name="password" value="' . $row['password'] .'"/><br /><br />';
print'<font face="AL-Hor" size="5" color="#AC8959" align=rigth> email </font><input type="text" name="email" value="' . $row['email'] . '" /><br />';
print'<br /><font face="AL-Hor" size="5" color="#AC8959" align=rigth> countery </font>
<select name=countery[] >
<option value="' . $row['countery'] .'">' . $row['countery'] .'</option>
<option value=countery>countery</option>
</select>
';
print'<br />
<input type="submit" name="submit" value="!Update" /></form>';
print'</div>';}
else { // Couldn't get the information.
print "<p>Could not retrieve the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>";
}
print '
</table>
';
?>
</div>
</td>
</div>
</td>
</tr>
</table>
</body>
</html>http://www.arbwb.com/img/download.php?f ... c76b9ea781
action code
Code: Select all
<?php
session_start();
if(!isset($_SESSION['loggedin'])) { print'<p align="right"><font size=4 face=AGA Dimnah Regular color=#DAB936> <b> your not register</font></b>
<br /> <a href="register.php"> register</a></p>';
exit(); }
?>
<html>
<style type="text/css">
body {
<?php
// Address error handing.
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);
// Check for a bg_color value.
if (isset ($_COOKIE['bg_color'])) {
print "\t\tbackground-color: {$_COOKIE['bg_color']};\n";
} else {
print "\t\tbackground-color: #ffffff;\n";
}
?>
}
</style>
<head>
<title>update page</title>
<!--favorite-->
<SCRIPT language="JavaScript1.2">
var bookmarkurl="http://localhost/finalproject/index.php";
var bookmarktitle="cook site";
function addbookmark(){
if (document.all)
window.external.AddFavorite(bookmarkurl,bookmarktitle);
}
</SCRIPT>
<!--end-favorite-->
</head>
<body>
<table border="0" width="97%" id="table1" height="693" cellspacing="0" cellpadding="0">
<tr>
<td height="19" colspan="2">
<p>
</td>
</tr>
<tr>
<td height="19" colspan="2">
<p dir="rtl" align="center">
</td>
</tr>
<tr>
<td height="133">
</td>
<td height="133" width="17%" background="image/43.gif">
<?php
if(isset($_SESSION['loggedin'])){
print '
<p align="center"><font size=3 face=AGA Dimnah Regular color=#826C51> <b> Hi <br/> ** ' .$_SESSION['loggedin'] . ' ** </font></b>
<br /></p>'; }?>
</td>
</tr>
<tr>
<td width="99%" background="image/32.gif" rowspan="2" colspan="2">
<div style="position: absolute; width: 552px; height: 303px; z-index: 1; left: 207px; top: 208px" id="layer1">
<?php
$dbc = @mysql_connect ('localhost','root','');
$db_selected = mysql_select_db('recipes_club', $dbc);
mysql_query("set charset cp1256");
$name=$_SESSION['loggedin'];
$password =$_POST['password'];
$email=$_POST['email'];
$countery=$_POST['countery'];
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);
$name=$_SESSION[loggedin];
if (empty ($password)) {
echo '<script language="javascript">
window.alert("please enter your password");
</script>';
}
else if (empty ($countery)) {
echo '<script language="javascript">
window.alert("choose your country");
</script>';
} ELSE{ if (is_array ($_POST['countery'])) {
foreach ($_POST['countery'] as $c)
$query = "UPDATE user SET password='{$_POST['password']}',countery='$c',email='{$_POST['email']}' WHERE name='$name'";
$r = mysql_query ($query); // Execute the query.
// Report on the result.
if (mysql_affected_rows() == 1) {
print '<br /> <p><div align=center><font face="AGA Dimnah Regular" color="#E3D1AC" size=10><br /><br /><b />your profile has been update</font></div></p>'; }
else {
print "<p>Could not update the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>"; }}
else { // Display the entry in a form.
// Check for a valid entry ID in the URL.
}
}
mysql_close();
?>
</div>
</td>
</div>
</td>
</tr>
</table>
</body>
</html>this is printscreen for it
http://www.arbwb.com/img/download.php?f ... e6979afe6b
so help me [s]plzzzzzzzzzzzzz[/s] please
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:11. Please use proper, complete spelling when posting in the forums. AOL Speak, leet speak and other abbreviated wording can confuse those that are trying to help you (or those that you are trying to help). Please keep in mind that there are many people from many countries that use our forums to read, post and learn. They do not always speak English as well as some of us, nor do they know these aberrant abbreviations. Therefore, use as few abbreviations as possible, especially when using such simple words.
Some examples of what not to do are ne1, any1 (anyone); u (you); ur (your or you're); 2 (to too); prolly (probably); afaik (as far as I know); etc.