...

View Full Version : session problems....



quintin
03-13-2007, 12:39 PM
i have a problem where i can only update the first name in my database details no matter whose logged in.here is the code.Any suggestions?

First part of the code
[php]
case 'detail':

echo '<p>
Please enter your details below.</p>
<form action="'.$_SERVER['PHP_SELF'].'" method="post">
<p>Price<br>
<input name="price" type="text" class="textBox"></p>
<p>Area:<br>
<input name="area" type="text" class="textBox"></p>
<p>Description<br>
<input name="description" type="text" class="textBox"></p>
<p><input type="submit" value="Edit Details" name="editdetail"></p>
</form>
';

break;

second part:
[php]
if(isset($_POST['editdetail']))
{
$username = $_SESSION['username'];
$price = trim($_POST['price']);
$area = trim($_POST['area']);
$description = trim($_POST['description']);
$do = mysql_query("UPDATE Users SET price = '$price' WHERE username='$username' LIMIT 1") or die(mysql_error());
$dotwo = mysql_query("UPDATE Users SET area = '$area' WHERE username='$username' LIMIT 1") or die(mysql_error());
$dothree = mysql_query("UPDATE Users SET description = '$description' WHERE username='$username' LIMIT 1") or die(mysql_error());

Fumigator
03-13-2007, 09:37 PM
Are you starting the session (http://us2.php.net/session_start)?

quintin
03-14-2007, 11:34 AM
yes the session has been started this is the code i used.
[php]
<?php
session_start();
if($_SESSION['s_logged_n'] == 'true'){
include 'process.php';
?>

Fumigator
03-14-2007, 04:08 PM
OK... have you made sure your $username variable is set properly-- that is to say, it contains the value you expect it to contain? Don't assume this is true-- add an echo statement to make sure it is true.

quintin
03-15-2007, 09:08 AM
so where do i put the echo statement ?

mlseim
03-15-2007, 02:32 PM
And try this too (the correct way to use the if statement with your session) ...

<?php
session_start();
if(isset($_SESSION['s_logged_n'])){
include 'process.php';

}
?>

SpinCode
03-15-2007, 04:35 PM
Dude,
I can't say for sure, because I never really think when I'm coding...it just flows naturally..but I once remembered something about similar name conflicts..
For example,
$username and $_SESSION["username"]

Try using different variable names..

I'm not entirely sure of this fixes your problem, but I am definitely sure there's a conflict problem between one of these types, such as $_SESSION["username"], and $_GET["username"] ...

Part and parcel of programming. Logic alone isn't sufficient to get you to the top.

Spin

mlseim
03-15-2007, 04:39 PM
SpinCode ...

You are correct ... I just went through that problem myself.

What occurred with me was similar. I had used "$user" as a session variable,
and also had a PHP email client that used the same variable for a session.
It sort of locked things up with the PHP email client. It took me a while to
figure out what was happening.

Once I changed the session variable on my admin page to "$aduser", it all
fell into place and worked fine.

Fumigator
03-15-2007, 09:13 PM
I hate the whole register_globals idea and this is a really good reason why it should die.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum