problems with my login

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • twodelay
    New Member
    • Nov 2007
    • 12

    problems with my login

    Hi, i don't know if anyone can help me. I'm really a novice to be honest. I have a site I'm working on and using some code I made with the help of a friend i set up a login system. It worked on the server we were using. But when i tried to adapt it to a different server for a website I needed this functionality for it doesn't seem to work.

    Somewhere in the transition something has either been lost or not added. I'm sure I've cover all the bases. I know there will be more info from me but if anyone can think of any obvious reasons that would be great I can then start to tick them off the list!

    I look forward to hearing from anyone!
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi. Welcome to TSDN!

    There are so many reasons why that could be happening I barely know where to start. It would help if you could post your code here, so we could see if we spot anything specific.

    The first things I'd look for is any code that relies on register_global s or something that loads resources from or links to an absolute path ("http://localhost/page.php" rather than "/page.php").

    But as I say, it's impossible to say unless we can have a look at your code.

    Comment

    • twodelay
      New Member
      • Nov 2007
      • 12

      #3
      Ok bit of a mess but here is the login code. its in a separate document called account.php. I have then used an include_once within the page i want it to appear. if that makes sense. anyway see below:


      [CODE=php]
      <?

      if ($_SESSION["userid"]) {
      ?>
      <link href="../../css/rollovers.css" rel="stylesheet " type="text/css" />
      <link href="../../css/styles.css" rel="stylesheet " type="text/css" />
      <link href="../../css/stylestext.css" rel="stylesheet " type="text/css" />

      <div id="signup"><di v id="blogspacer" ></div>
      <p class="bodybold blue">Logged in</p>
      <?=$loginerror? >
      <p class="loginbod y">You are currently logged in as <strong>
      <?=$member["member_nam e"]?>
      </strong></p>
      <p><a class="loginbod y" href='<?=$_SERV ER['PHP_SELF']?>?logout=true< ?=($_GET["id"]) ? "&id=".$_GE T["id"] : "";?>'>Clic k here to log out</a></p>
      </div>
      <div id="blogspacer" ></div>
      <?
      }
      else {
      ?>
      <div id="signup"><di v id="blogspacer" ></div>
      <form action='<?=$_SE RVER['PHP_SELF']?><?=($_GET["id"]) ? "?id=".$_GE T["id"] : "";?>' method='POST'/>
      <p class="bodybold blue">Blog Login</p>
      <p class="loginbod y">Username <br /><input name='un' type='text' class="loginbod y" size='20'/>
      </p><p class="loginbod y">Password <br /><input name='pw' type='password' class="loginbod y" size='20'/>
      </p><p><input type='submit' class="loginbod y" value='Login'/></p>
      </div>
      <div id="blogspacer" ></div>
      <?
      }

      ?>
      [/CODE]

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        Ahh ok.

        Before you change anything, change the short-tags into real PHP tags.
        Short-tags are disabled by default in PHP and you should avoid using them at all times. They are a little shorter, but honestly, their nothing but trouble.

        That is:
        [code=php]
        # Change these tags:
        <? .. ?>
        <?=$var?>

        # Into these tags:
        <?php ... ?>
        <?php echo $var; ?>
        [/code]

        Comment

        • twodelay
          New Member
          • Nov 2007
          • 12

          #5
          Originally posted by Atli
          Ahh ok.

          Before you change anything, change the short-tags into real PHP tags.
          Short-tags are disabled by default in PHP and you should avoid using them at all times. They are a little shorter, but honestly, their nothing but trouble.

          That is:
          [code=php]
          # Change these tags:
          <? .. ?>
          <?=$var?>

          # Into these tags:
          <?php ... ?>
          <?php echo $var; ?>
          [/code]

          Cool, i will sort this and let you know when its done. Thanks for your help so far.... and thanks in anticipation of your help to come!

          Comment

          • twodelay
            New Member
            • Nov 2007
            • 12

            #6
            [CODE=php]
            <?php if ($_SESSION["userid"]) {?>
            <link href="../../css/rollovers.css" rel="stylesheet " type="text/css" />
            <link href="../../css/styles.css" rel="stylesheet " type="text/css" />
            <link href="../../css/stylestext.css" rel="stylesheet " type="text/css" />

            <div id="signup"><di v id="blogspacer" ></div>
            <p class="bodybold blue">Logged in</p>
            <?php echo $loginerror?>
            <p class="loginbod y">You are currently logged in as <strong>
            <?php echo $member["member_nam e"]?>
            </strong></p>
            <p><a class="loginbod y" href='<?php echo $_SERVER['PHP_SELF']?>?logout=true< ?php echo ($_GET["id"]) ? "&id=".$_GE T["id"] : "";?>'>Clic k here to log out</a></p>
            </div>
            <div id="blogspacer" ></div>
            <?php
            }
            else {
            ?>
            <div id="signup"><di v id="blogspacer" ></div>
            <form action='<?php echo $_SERVER['PHP_SELF']?><?=($_GET["id"]) ? "?id=".$_GE T["id"] : "";?>' method='POST'/>
            <p class="bodybold blue">Blog Login</p>
            <p class="loginbod y">Username <br /><input name='un' type='text' class="loginbod y" size='20'/>
            </p><p class="loginbod y">Password <br /><input name='pw' type='password' class="loginbod y" size='20'/>
            </p><p><input type='submit' class="loginbod y" value='Login'/></p>
            </div>
            <div id="blogspacer" ></div>
            <?php
            }

            ?>
            [/CODE]

            Ok so i have changed the short tags. It still does nothing when i try to log in. What do you think the next step is?
            Last edited by Atli; Nov 12 '07, 01:46 PM. Reason: Changed [code] tags to [code=php].

            Comment

            • Atli
              Recognized Expert Expert
              • Nov 2006
              • 5062

              #7
              I can't see anything wrong with that particular code, except that you missed one short-tag in line 20.

              There doesn't seem to be any code there to process the form data that is posted if the Session variable in line 1 is false, which I would guess is the code that actually logs the user in. Could the problem be there?

              Comment

              • twodelay
                New Member
                • Nov 2007
                • 12

                #8
                Originally posted by Atli
                I can't see anything wrong with that particular code, except that you missed one short-tag in line 20.

                There doesn't seem to be any code there to process the form data that is posted if the Session variable in line 1 is false, which I would guess is the code that actually logs the user in. Could the problem be there?
                Well from what you said in my limited knowledge I would have thought that that might be a problem, however, it is the same code as as i used before, which worked. Grr this is complicated. The thing that bugs me is that it seems as if its not even processing anything. When you submit illegal characters or incorrect login it doesnt come up with the error message that has been set up.

                I will cross reference this with my old files and see if i can see anything in the code.

                Comment

                • twodelay
                  New Member
                  • Nov 2007
                  • 12

                  #9
                  Ok i have racked my brains and cant see or find anything that is different to the other version i did (that worked) other than stylesheets etc.

                  You mentioned:

                  There doesn't seem to be any code there to process the form data that is posted if the Session variable in line 1 is false, which I would guess is the code that actually logs the user in. Could the problem be there?
                  Could you suggest what changes i could make to correct this... so sorry as you can tell I'm very, very poor at this! thanks for your help.

                  Comment

                  • Atli
                    Recognized Expert Expert
                    • Nov 2006
                    • 5062

                    #10
                    I could probably see if there are problems with the code, if I could see it :)
                    Just the part where you fetch the POST values and where you log the user in.

                    My first guess would be it has something to do with the register_global s directive, but there is really no way to tell unless I see the code.

                    Just out of curiosity, which version of PHP did this code work on? And which version are you trying to use it on now?

                    Could you create a new .php file with the following content, run it and find the value of the 'short_open_tag ' directive and the 'register_globa ls' directive?
                    [code=php]
                    <?php echo phpinfo(); ?>
                    [/code]

                    Comment

                    • LacrosseB0ss
                      New Member
                      • Oct 2006
                      • 112

                      #11
                      From my previous experiences, ASP and such will not work on Linux servers. Is the same true for the reverse? i.e. Will PHP work on a Windows server? Off the top of my head that's what I am thinking.

                      This Article claims some versions of Windows do not support PHP. And some PHP versions aren't set up to run. You can read the article for more.

                      Now, I could just be blowing smoke. I don't really know if this is correct or not. Just throwing ideas out there but I know ASP won't work on Linux (where PHP can be used). Perhaps your old server was Linux based and the new one is Windows based. I'd contact your server owner to find out.

                      - LB

                      Comment

                      • twodelay
                        New Member
                        • Nov 2007
                        • 12

                        #12
                        Originally posted by LacrosseB0ss
                        From my previous experiences, ASP and such will not work on Linux servers. Is the same true for the reverse? i.e. Will PHP work on a Windows server? Off the top of my head that's what I am thinking.

                        This Article claims some versions of Windows do not support PHP. And some PHP versions aren't set up to run. You can read the article for more.

                        Now, I could just be blowing smoke. I don't really know if this is correct or not. Just throwing ideas out there but I know ASP won't work on Linux (where PHP can be used). Perhaps your old server was Linux based and the new one is Windows based. I'd contact your server owner to find out.

                        - LB
                        Hi thanks for the suggestion but it does have PHP installed on the server. I made sure of that when setting up the account. It has PHPmyAdmin pre-installed. I think it might be something to do with PHP 4 or 5 or something!

                        thanks.

                        Comment

                        • twodelay
                          New Member
                          • Nov 2007
                          • 12

                          #13
                          Originally posted by Atli
                          I could probably see if there are problems with the code, if I could see it :)
                          Just the part where you fetch the POST values and where you log the user in.

                          My first guess would be it has something to do with the register_global s directive, but there is really no way to tell unless I see the code.

                          Just out of curiosity, which version of PHP did this code work on? And which version are you trying to use it on now?

                          Could you create a new .php file with the following content, run it and find the value of the 'short_open_tag ' directive and the 'register_globa ls' directive?
                          [code=php]
                          <?php echo phpinfo(); ?>
                          [/code]
                          Ok i ran the PHP info document.

                          The short_open_tag is set to 'on' and the register_global s is also set as 'on'

                          does that help?

                          It is also PHP 4.... 4.4.7 to be exact. Im pretty sure the PHP im using is 4.

                          I noticed that the Register_global s on the previous server i used was set to off. Does this make a difference... it was also using PHP 4.4.6

                          hope some of this makes sense.

                          Comment

                          • twodelay
                            New Member
                            • Nov 2007
                            • 12

                            #14
                            I have been in touch with the hosting company as i figured they would have to change the register_global s. they said that there is a .htaccess file on the live directory already that i can access and change.

                            Only, showing my inexperience and lack of knowledge again, i dont know how to get it. Ive looked through dreamweaver and cant see it. I used an independent FTP client and i can see the .htaccess file but cant download a copy to edit.

                            If anyone can shed some light on this that would be great. Thanks.

                            Comment

                            • Atli
                              Recognized Expert Expert
                              • Nov 2006
                              • 5062

                              #15
                              I wouldn't worry about changing that. If both the 'register_globa ls' and the 'short_open_tag s' are on, neither of them will cause your code to stop functioning.

                              Now we know that neither of those two are the cause of your problem, we really need to see the login code to have any chance of finding the problem.

                              If you could find the login code and post it here, I could look through it and see if I spot anything that may be causing this.

                              Comment

                              Working...