Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Php creating new user everytime

  • 25-10-2012 4:25pm
    #1
    Registered Users, Registered Users 2 Posts: 620 ✭✭✭


    Hey guys I hope i am posting in the right forum. I am building my first site for college and and have the majority of the groundwork completed. I am using dreamweaver so it is generating the PHP for me(Dont really understand php enough to write myself). I will post the code and a screenshot to give a better idea of what i am asking.

    Basically my problem is when I select an item from the drop down tables and logged in it does not write to my user id. For example If i select Chelsea for the Premier League instead of writing to the premier league field on my user table it creates a whole new user id. I think the problem must be when i am creating a session(I have no experience in creating sessions so am probably doing it wrong!)

    If anyone can point me in the right direction that would be great. I will post my code if required, the page is 500 lines or that so i dont want to overwhelm the post!


Comments

  • Closed Accounts Posts: 6,281 ✭✭✭Ricky91t


    It sounds like on every page re-load you're creating a new session no matter what, this means your old session(possibly with the bet logged) is getting wiped and a new one replacing it.

    Post your code on pastebin and post the link here. Make sure you set the syntax highlighting to PHP as it'll be easier on the eye.


  • Registered Users, Registered Users 2 Posts: 620 ✭✭✭Laika1986


    Hey thanks for your reply. I have fixed that problem, I was inserting a record(which creates a new row) instead of updating a record. My problem now is regardless of what user is logged in it updates the record on the first row everytime. Any suggestions?

    http://pastebin.com/MLZuwKvR


  • Closed Accounts Posts: 6,281 ✭✭✭Ricky91t


    Having a look at your code you use both $_POST and $_SESSION at different points.

    Add this code somewhere in your HTML and see what the output is for different users, maybe you've an issue where each user has the same ID.:

    [PHP]
    <?php
    if(isset($_POST)){
    echo "<p>The posted userid is: {$_POST} .</p>";
    }else{
    echo "<p>POST userid not set.</p>";
    }

    echo "<p>The session userid is: {$_SESSION} .</p>";

    ?>[/PHP]


  • Registered Users, Registered Users 2 Posts: 620 ✭✭✭Laika1986


    Hey I pasted in the code and have attached the screenshot of the outcome. To me that means that the user session isnt being created at all. I will read up on the differences between POST and SESSION now. Again thanks for your help, Could you put an estimate on how big a problem it is?


Advertisement