|
You are forgetting to terminate the session on logout, or at least clear out the session variables that you are using to detect if someone is logged in.
Because it is so hard to Google for how to terminate a session, here is the link http://www.php.net/manual/en/function.session-destroy.php[^]
|
|
|
|
|
On the logout.php you need to set up this
session_unset() ;
session_destroy() ;
www.malorgio.it
|
|
|
|
|
You can also store sessions to database it is a good way to manage user sessions.
Arunkumar
|
|
|
|
|
what is the regex to replace only the last comma, using preg_replace? Thanks
|
|
|
|
|
It goes something like /,[^,]*$/ Fire up expresso and try it. The logic is "comma, any number of non-commas, end" So all but the last comma will fail the second part.
Cheers,
Peter
ps There is a regex forum here. Next time...
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
hello there
i want to update multiple rows which comes from a dynamic table in Dreamweaver CS5 (a loop in php) here is my Mysql table :
CREATE TABLE `register`.`s_lessons` (<br />
`lid` int( 5 ) NOT NULL ,<br />
`sid` int( 9 ) NOT NULL ,<br />
`term` int( 5 ) NOT NULL ,<br />
`tid` int( 5 ) NOT NULL ,<br />
`point` double NOT NULL DEFAULT '0',<br />
PRIMARY KEY ( `lid` , `sid` , `term` ) ,<br />
KEY `tid` ( `tid` ) ,<br />
KEY `point` ( `point` )<br />
) ENGINE = MYISAM DEFAULT CHARSET = utf8 COLLATE = utf8_persian_ci;
and this is my page source code:
<?php require_once('../Connections/register.php'); ?><br />
<?php<br />
session_start();<br />
if (!function_exists("GetSQLValueString")) {<br />
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") <br />
{<br />
if (PHP_VERSION < 6) {<br />
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;<br />
}<br />
<br />
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);<br />
<br />
switch ($theType) {<br />
case "text":<br />
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";<br />
break; <br />
case "long":<br />
case "int":<br />
$theValue = ($theValue != "") ? intval($theValue) : "NULL";<br />
break;<br />
case "double":<br />
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";<br />
break;<br />
case "date":<br />
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";<br />
break;<br />
case "defined":<br />
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;<br />
break;<br />
}<br />
return $theValue;<br />
}<br />
}<br />
<br />
$colname1_rs1 = "-1";<br />
if (isset($_GET['term'])) {<br />
$colname1_rs1 = $_GET['term'];<br />
}<br />
$colname_rs1 = "-1";<br />
if (isset($_GET['lid'])) {<br />
$colname_rs1 = $_GET['lid'];<br />
}<br />
$colname2_rs1 = "-1";<br />
if (isset($_SESSION['tid'])) {<br />
$colname2_rs1 = $_SESSION['tid'];<br />
}<br />
mysql_select_db($database_register, $register);<br />
$query_rs1 = sprintf("SELECT s_lessons.sid, s_lessons.lid, s_lessons.term, s_lessons.tid, s_lessons.point FROM s_lessons WHERE s_lessons.lid = %s AND s_lessons.term = %s AND s_lessons.tid = %s", GetSQLValueString($colname_rs1, "int"),GetSQLValueString($colname1_rs1, "int"),GetSQLValueString($colname2_rs1, "int"));<br />
$rs1 = mysql_query($query_rs1, $register) or die(mysql_error());<br />
$row_rs1 = mysql_fetch_assoc($rs1);<br />
$totalRows_rs1 = mysql_num_rows($rs1);<br />
$count=mysql_num_rows($rs1);<br />
<br />
<br />
<br />
$editFormAction = $_SERVER['PHP_SELF'];<br />
if (isset($_SERVER['QUERY_STRING'])) {<br />
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);<br />
}<br />
<br />
for ($j = 0, $len = count($_POST['lid']); $j < $len; $j++) {<br />
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {<br />
$updateSQL = sprintf("UPDATE s_lessons SET point=%s WHERE tid=%s, lid=%s, sid=%s, term=%s",<br />
GetSQLValueString($_POST['point'] [$j], "double"),<br />
GetSQLValueString($_SESSION['tid'], "int"),<br />
GetSQLValueString($_POST['lid'] [$j], "int"),<br />
GetSQLValueString($_POST['sid'] [$j], "int"),<br />
GetSQLValueString($_POST['term'] [$j], "int"));<br />
<br />
mysql_select_db($database_register, $register);<br />
$Result1 = mysql_query($updateSQL, $register) or die(mysql_error());<br />
}<br />
$updateGoTo = "student_lists.php";<br />
if (isset($_SERVER['QUERY_STRING'])) {<br />
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";<br />
$updateGoTo .= $_SERVER['QUERY_STRING'];<br />
}<br />
header(sprintf("Location: %s", $updateGoTo));<br />
}<br />
<br />
?><br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><br />
<html xmlns="http://www.w3.org/1999/xhtml"><br />
<head><br />
<meta name="keywords" content="" /><br />
<meta name="description" content="" /><br />
<meta http-equiv="content-type" content="text/html; charset=utf-8" /><br />
<title>r</title><br />
<link href="styles/style.css" rel="stylesheet" type="text/css" media="screen" /><br />
<link href="styles/in_styles.css" rel="stylesheet" type="text/css" media="screen" /><br />
</head><br />
<body><br />
<div id="wrapper"><br />
<div id="header-wrapper"><br />
<br />
</div><br />
<!-- end #header --><br />
<div id="page"><br />
<div id="page-bgtop"><br />
<div id="page-bgbtm"><br />
<div id="content"><br />
<div class="post"><br />
<div style="clear: both;"><br />
<form name="form1" id="form1" method="post" action="<?php echo $editFormAction; ?>"><br />
<table border="1" align="center"><br />
<tr><br />
<th>Student ID</th><br />
<th>Lesson ID</th><br />
<th>Semester</th><br />
<th>Point</th><br />
<br />
</tr><br />
<?php do { ?><br />
<tr><br />
<td class="data"><label for="sid[]"></label><br />
<input name="sid[]" type="text" id="sid[]" value="<?php echo $row_rs1['sid']; ?>" size="9" readonly="readonly" /></td><br />
<td class="data"><label for="lid[]"></label><br />
<input name="lid[]" type="text" id="lid[]" value="<?php echo $row_rs1['lid']; ?>" size="5" readonly="readonly" /></td><br />
<td class="data"><label for="term[]"></label><br />
<input name="term[]" type="text" id="term[]" value="<?php echo $row_rs1['term']; ?>" size="4" readonly="readonly" /></td><br />
<td><label for="point[]"></label><br />
<input name="point[]" type="text" id="point[]" value="<?php echo $row_rs1['point']; ?>" size="4" /> <br />
</tr><br />
<br />
<?php } while ($row_rs1 = mysql_fetch_assoc($rs1)); ?><br />
</table><br />
<p><br />
<input type="submit" name="Submit" id="Submit" value="Submit" /><br />
<input type="hidden" name="MM_update" value="form1" /><br />
</p><br />
</form><br />
</div><br />
</div><br />
<div style="clear: both;"><br />
</div><br />
</div><br />
<!-- end #content --><br />
<br />
<!-- end #sidebar --><br />
<div style="clear: both;"> </div><br />
</div><br />
</div><br />
</div><br />
<!-- end #page --><br />
</div><br />
<!-- end #footer --><br />
</body><br />
</html><br />
<?php<br />
mysql_free_result($rs1);<br />
?>
All i want is that when users click on SUBMIT button values of point column in s_lessons(database table) be updated by new entries from user.
i did my best and result with that code is :
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' lid=888, sid=860935422, term=902' at line 1
I would appreciate any idea.
with prior thanks
|
|
|
|
|
Your problem is in the Query you are using to update the record:
UPDATE s_lessons SET point=%s WHERE tid=%s, lid=%s, sid=%s, term=%s
Is not valid Sql, and should be something like
UPDATE s_lessons SET point=%s WHERE tid=%s and lid=%s and sid=%s and term=%s
You might wanna read up a bit on the SQL update syntax[^]
|
|
|
|
|
what a silly mistake!
you are right.i changed it and the problem solved!
thank you very much.
|
|
|
|
|
Does anyone know if samba has certain supported/preferred file systems? ...or does it not matter?
I'll be accessing the share with:
- Ubuntu Lucid
- Windows XP, Vista, 7
|
|
|
|
|
Went with ext4, doesn't seem to really matter since samba doesn't really allow for direct access... Windows machines seem to be ok with it...
|
|
|
|
|
Samba operates through the VFS (virtual file system), so anything you can use in Linux, Samba will be able to use and share it.
--
Kein Mitleid Für Die Mehrheit
|
|
|
|
|
What I'm trying to do should be simple but for some reason it's not. All I want right now is to display one of my session variables on the page (this way I know it's what I think it is).
I have <td><input name="myusername" type="text" id="myusername" style="width:150px"></td> on the first form to get the value and then session_register("myusername"); on the next page to assign the value to the session variable.
I then have (this is the very top of the page (page 3))
<?php
session_start();
if (!session_is_registered(myusername)) {
header("location:login.php");
}
?>
Test
<?php
$test = $_SESSION["myusername"];
echo $test;
?>
On the "last" page... the page isn't redirecting so I know the value is "good" but for some reason I can't get it to display. It's just displaying 'Test'...
|
|
|
|
|
5.1.6
However stupid here realized that he forgot to actually assign the session variable a value. I guess the important thing is I figured it out
|
|
|
|
|
Thanks for the FYI, I'll account for it now before I forget about it.
|
|
|
|
|
I figured out my problem... as usual forgot the most simple aspect of programming $_SESSION['myusername'] = $myusername;
I really does help to actually assign a value to something... Hopefully this will help someone else that finds them self in the same lack of sleep state.
|
|
|
|
|
Even though you seem to have found a solution, I have actually found some web hosting to be quite a pain if you are using Sessions. Depends on the provider though. With my current provider it was becoming way to complicated to set up properly so I used another method
|
|
|
|
|
This is just for a small intranet site. I think the most users I've ever had on at one time is 5
However I'm always looking for ideas.
|
|
|
|
|
Good luck with intranet site hope you don't find too many more issues.
On my website in the end I reverted to cookies. When the user logs in it stores the information they typed in the form in 2 cookies (nom). Then every time any page loads I check it against the database, thus maintaining some form of security
|
|
|
|
|
I was having a heck of a time with cookies in a terminal services environment. Not really sure why that made a difference, but maybe I'll look back into that again in the future.
|
|
|
|
|
Hello all,
In a piece of PHP code, I'm trying to set two styles at the same time for a set of dynamically created divs...
The code I'm trying to use is:
echo('<div id="'.$DivId.'" style=width:'.$width.'; display:none>;');
As you can see $DivId is a variable that depends on a loop.
I need to set the width (another parameter).
And at the beginning that DIV must be not shown hence the display:none.
If I try to modify the style one at a time it works well... I mean that if I try to change the width only or the display only it works well... but I don't know how to chain the two changes.
Any advice?
Thank you in advance!
PS: I've tried to Google for "php more than one style", "php change styles", "php style guide"... no luck here...
|
|
|
|
|
I tried the solution in the third link and all the solutions that Graham is proposing and none of them worked...
Somehow a problem must be there that doesn't allow it to work... it is like the display:none modifier that I'm adding would avoid anything else to work...
Thank you for trying!
|
|
|
|
|
I've found the problem...
It happens that the TinyMCE editor window that I'm using in that place doesn't override the style when using display:none in the div that it is contained...
AMAZING.
Well, I've found that this has happened to lots of people and a trick to cheat that...
It is a PITA when you put efforts and time to solve things that should be working ok...
Many thanks for helping me.
|
|
|
|
|
It looks like you're not quoting the style, so the attribute is being broken on the space in the middle - try this:
echo('<div id="'.$DivId.'" style="width:'.$width.'; display:none>;"');
or this:
echo('<div id="'.$DivId.'" style=width:'.$width.';display:none>;');
|
|
|
|
|
Using the first option (quoted) the width is applied but the display:none is not.
Using the second of those options (no space) the width is not being modified and only display:none works.
PS: it is like if the display:none would destroy all the other options out there...
Thank you for trying...
|
|
|
|
|
That sounds very odd... What is the value of $width ?
|
|
|
|