what s wrong with my code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • amrhi
    New Member
    • Sep 2006
    • 22

    what s wrong with my code

    Whats wrong with my code , i cant access to next page.
    Looks like the text field cant be read by login.php
    Thanks
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    <!--
    .style1 {color: #0000FF}
    .style2 {color: #392CB8}
    .style3 {
    	font-family: Geneva, Arial, Helvetica, sans-serif;
    	font-weight: bold;
    }
    .style6 {
    	font-size: 12px;
    	font-style: italic;
    }
    .style9 {font-size: 12px}
    .style10 {color: #0000FF; font-size: 12px; }
    .style11 {
    	font-size: 12;
    	font-weight: bold;
    	color: #FFFFFF;
    }
    .style12 {color: #FFFFFF}
    -->
    </style>
    </head>
    
    <body>
    <table width="797" border="0" cellpadding="0" cellspacing="0">
      <!--DWLayoutTable-->
      <tr>
        <td height="150" colspan="2" valign="top" bordercolor="#392CB8" bgcolor="#392CB8"><div align="center" class="style2"><img src="images/banner.jpg" width="797" height="150" align="top"></div></td>
      </tr>
      <tr>
        <td width="180" height="50" valign="top" bgcolor="#392CB8"><table width="200" border="1" align="center" bordercolor="#392CB8" bgcolor="#392CB8">
          <!--DWLayoutTable-->
          <tr>
            <td><!--DWLayoutEmptyCell-->&nbsp;</td>
          </tr>
        </table></td>
        <td width="617" valign="top" bgcolor="#392CB8"><table width="300" border="1" align="center" bordercolor="#392CB8" bgcolor="#392CB8">
            <tr>
              <td width="61"><span class="style12"><a href="coba.php">[Home]</a></span></td>
              <td width="8">&nbsp;</td>
              <td width="112"><span class="style12">[Information]</span></td>
              <td width="8">&nbsp;</td>
              <td width="50"><div align="right" class="style12">[User]</div></td>
              <td width="21">&nbsp;</td>
              <td width="15"><span class="style12">[Administrator]</span></td>
            </tr>
        </table></td>
      </tr>
    </table>
    <table width="803" height="587" border="0" cellpadding="0" cellspacing="0">
      <!--DWLayoutTable-->
      <tr>
        <td width="189" height="132" align="center" valign="middle" bordercolor="#392CB8" bgcolor="#392CB8" class="style1"><div align="right"></div>      <div align="right">
            <p align="center"><img src="images/gp.jpg" width="99" height="94"></p>
          </div></td>
        <td colspan="9" rowspan="3" valign="top"><form name="form1" method="post" action="">
        </form>
          <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <form action="login.php" method="post" name="form2">
          <table width="254" border="1" align="center" id="table1">
            <tr>
              <td colspan="2"><div align="center">Please Login </div></td>
              </tr>
            <tr>
              <td width="94">User Name </td>
              <td width="144"><input name="txtuser" type="text" id="txtuser"></td>
            </tr>
            <tr>
              <td>Password</td>
              <td><input name="txtpass" type="password" id="txtpass"></td>
            </tr>
            <tr>
              <td colspan="2">&nbsp;</td>
              </tr>
            <tr>
              <td colspan="2"><div align="center">
                <input name="login" type="submit" id="login" value="LOGIN">
                <input type="reset" name="Submit2" value="RESET">
              </div></td>
              </tr>
          </table>
        </form>    <p>&nbsp;</p></td>
        <td width="1"></td>
      </tr>
    	     <tr>
    	         <td height="343" valign="middle" bgcolor="#392CB8"><p align="center" class="style11">&nbsp;</p>      
    	           <p align="center">&nbsp;</p>      <p>&nbsp;</p>      <p>&nbsp;</p></td>
    	         <td></td>
        </tr>     		 
        <tr>
          <td rowspan="5" valign="top" bgcolor="#392CB8"><p>&nbsp;</p>
            <p>&nbsp;</p>
            <p><span class="style1">
            </span></p>
            <p>&nbsp;</p>
            <p>&nbsp;</p>
            <p>&nbsp;</p>        <p><span class="style1">
          </span></p></td>
          <td height="143"></td>
        </tr>
    				
      <tr>
        <td height="32" colspan="8" valign="top"><div align="left"><span class="style1">
        </span></div></td>
        <td width="16"></td>
        <td></td>
      </tr>
      <tr>
        <td width="62" height="19">&nbsp;</td>
        <td width="9">&nbsp;</td>
        <td colspan="4" valign="top"><div align="left" class="style1 style3"><em> POWER BY OPEN SOURCE : </em></div></td>
        <td width="4"></td>
        <td width="30"></td>
        <td></td>
        <td></td>
      </tr>
      <tr>
        <td height="55">&nbsp;</td>
        <td colspan="2" valign="top"><div align="center"><img src="images/php5.jpg" width="70" height="47"></div></td>
        <td width="149" valign="top"><div align="center"><img src="images/mysql.gif" width="112" height="40"></div></td>
        <td width="119" valign="top"><div align="center"><img src="images/wamp5.jpg" width="68" height="44" align="middle"></div></td>
        <td width="121" valign="top"><div align="center"><img src="images/apache.jpg" width="60" height="47"></div></td>
      <td></td>
        <td></td>
        <td></td>
        <td></td>
      </tr>
      <tr>
        <td height="26">&nbsp;</td>
        <td colspan="6" valign="top"><div align="center" class="style6">CREATED BY CGK-INNOVATION 2007 </div></td>
        <td></td>
        <td></td>
        <td></td>
      </tr>
      <tr>
        <td height="0"></td>
        <td></td>
        <td></td>
        <td width="103"></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
      </tr>
    </table>
    </body>
    </html>
    Code:
    <?php
    session_start();
    session_register("username");
    ?>
    <table width="149" border="0" cellpadding="0" cellspacing="0">
      <!--DWLayoutDefaultTable-->
      <tr>
        <td width="9" height="57">&nbsp;</td>
        <td width="140" valign="top"><a href="index.htm">back to main page</a> </td>
      </tr>
    </table>
    <?php
    if ((!$txtuser) or(!$txtpass)){
    echo"<br>";
    echo "User Name:$txtuser";
    echo "<br>";
    echo "Wrong Password ";
    }else
    {
    include "koneksi.php";
    $txtpass=md5($password);
    $query_login=mysql_query("select * from tbluser where username='$txtuser' and password='$txtpass'",$koneksi) or die (mysql_error());
    while($row=mysql_fetch_array($query_login))
    {
    if($txtpass=="$row[password]" && $txtuser=="$row[username]")
    {
    header("location:./login/user.php");
    }
    else
    header("location:./index.php?error=1");
    }}
    ?>
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    You posted your values to login.php. So the question is: where did you assign the values to these variables from the $_POST array in LOGIN.PHP?
    Code:
    if ((!$txtuser) or(!$txtpass)){
    Ronald :cool:

    Comment

    • xwero
      New Member
      • Feb 2007
      • 99

      #3
      The globals will be off and that's a good thing. To get posted and url parameter values use $_POST and $_GET.

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        Originally posted by xwero
        The globals will be off and that's a good thing.
        What do I do with this statement or what message are you conveying? Please explain.

        Ronald :cool:

        Comment

        • xwero
          New Member
          • Feb 2007
          • 99

          #5
          if the globals in the php ini are on you can retrieve post and get variables like they were self defined variables hence the txtuser and textpass variables.

          now hosting compagnies are beginning to use that setting in the off state because they are switching to php 4.2. I think this is what is happening with amrhis hosting.

          It happened to a site of mine i made a few years ago too a month ago. if you are used to work with the globals setting on it breaks all code that is based on http actions.

          register_global s is the setting i'm talking about

          Comment

          • ronverdonk
            Recognized Expert Specialist
            • Jul 2006
            • 4259

            #6
            Thank you for your explanation.

            You are right that a lot of programmers still don't know that globals are set off by most server providers nowadays. And that, for that reason, a lot of 'old' applications run into problems.

            Ronald :cool:

            Comment

            • amrhi
              New Member
              • Sep 2006
              • 22

              #7
              Thanks guys for your help..........!
              it works now.

              Comment

              Working...