Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    session problems....

    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());
    Last edited by quintin; 03-13-2007 at 12:48 PM.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts

  • #3
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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';
    ?>

  • #4
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    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.

  • #5
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    so where do i put the echo statement ?

  • #6
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,503
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    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';

    }
    ?>

  • #7
    New Coder
    Join Date
    Jan 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Avoid using similar names

    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

  • #8
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,503
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    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.

  • #9
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    I hate the whole register_globals idea and this is a really good reason why it should die.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •