SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Dec 2000
    Location
    Karachi, Pakistan
    Posts
    913
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Validation Problem

    Hello Guys..

    I have this code for validating a user but it is giving the same login screen saying that username does not exists while I know that it is there.

    Here is the code:

    PHP Code:
    <?php
    include('functions.php');
    ?>

    <html>
    <!-- #BeginTemplate "/Templates/pstennis.dwt" --> 
    <head>
    <!-- #BeginEditable "doctitle" --> 
    <title>Photoshop Tennis:: where creativity meets challenges</title>
    <!-- #EndEditable --> 
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link rel="stylesheet" href="css.css" type="text/css">
    </head>
    <body bgcolor="#FFFFFF" text="#000000" topmargin="5" marginwidth="0" marginheight="0" leftmargin="0" link="#CCCCCC" vlink="#CCCCCC" alink="#CCCCCC">
    <table width="770" border="0" cellspacing="0" cellpadding="0" align="center" height="551">
      <tr> 
        <td valign="top" height="545"> 
          <!--main table -->
          <table width="100%" border="0" cellspacing="0" cellpadding="0" height="540">
            <tr> 
              <td> <img src="images/logo.gif" width="770" height="75"></td>
            </tr>
            <tr> 
              <td> 
                <table width="100%" border="0" cellspacing="0" cellpadding="0" class="nav_top" bordercolor="#FFFFFF">
                  <tr> 
                    <td width="9%"> 
                      <div align="center"><a href="index.php">home</a></div>
                    </td>
                    <td width="12%"> 
                      <div align="center"><a href="signup.php">signup</a></div>
                    </td>
                    <td width="15%"> 
                      <div align="center">members</div>
                    </td>
                    <td width="12%"> 
                      <div align="center">challenges</div>
                    </td>
                    <td width="12%"> 
                      <div align="center">control panel</div>
                    </td>
                    <td width="12%"> 
                      <div align="center">about us</div>
                    </td>
                    <td width="12%"> 
                      <div align="center">terms</div>
                    </td>
                    <td width="16%"> 
                      <div align="center">what is PS-Tennis</div>
                    </td>
                  </tr>
                </table>
              </td>
            </tr>
            <tr> 
              <td valign="top" height="462"> <br>
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr> 
                    <td width="24%" valign="top" height="404"> 
                      <table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr> 
                          <td valign="top" height="56"> 
                            <table width="100%" border="1" cellspacing="0" cellpadding="0" bordercolor="#000000">
                              <tr> 
                                <td valign="top" height="65"> 
                                  <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <tr> 
                                      <td class="nav_top">user info</td>
                                    </tr>
                                    <tr> 
                                      <td class="left_nav" valign="top" height="47">You 
                                        are not logged in. Click here to login in 
                                        or signup for <b>free</b>.</td>
                                    </tr>
                                  </table>
                                </td>
                              </tr>
                            </table>
                          </td>
                        </tr>
                        <tr> 
                          <td valign="top" height="5">&nbsp; </td>
                        </tr>
                        <tr> 
                          <td valign="top"> 
                            <table width="100%" border="1" cellspacing="0" cellpadding="0" bordercolor="#000000">
                              <tr> 
                                <td> 
                                  <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <tr> 
                                      <td class="nav_top">latest member</td>
                                    </tr>
                                    <tr> 
                                      <td class="left_nav" valign="top">Welcome our 
                                        latest member </td>
                                    </tr>
                                    <tr> 
                                      <td class="left_nav">&nbsp;</td>
                                    </tr>
                                  </table>
                                </td>
                              </tr>
                            </table>
                          </td>
                        </tr>
                        <tr> 
                          <td>&nbsp;</td>
                        </tr>
                        <tr> 
                          <td valign="top"> 
                            <table width="100%" border="1" cellspacing="0" cellpadding="0" bordercolor="#000000">
                              <tr> 
                                <td> 
                                  <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <tr> 
                                      <td class="nav_top">latest challenges</td>
                                    </tr>
                                    <tr> 
                                      <td class="left_nav" valign="top">The last challenge 
                                        recorded in our database is against --- and 
                                        ***. Click for see the serves made by each 
                                        member.</td>
                                    </tr>
                                    <tr> 
                                      <td class="left_nav">&nbsp;</td>
                                    </tr>
                                  </table>
                                </td>
                              </tr>
                            </table>
                          </td>
                        </tr>
                        <tr> 
                          <td>&nbsp;</td>
                        </tr>
                        <tr> 
                          <td valign="top" height="2"> 
                            <table width="100%" border="1" cellspacing="0" cellpadding="0" bordercolor="#000000">
                              <tr> 
                                <td> 
                                  <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <tr> 
                                      <td class="nav_top">adertisement</td>
                                    </tr>
                                    <tr> 
                                      <td class="left_nav" valign="top" height="25"> 
                                        <div align="center">some banners or image 
                                          or may be text here</div>
                                      </td>
                                    </tr>
                                    <tr> 
                                      <td class="left_nav">&nbsp;</td>
                                    </tr>
                                  </table>
                                </td>
                              </tr>
                            </table>
                          </td>
                        </tr>
                      </table>
                    </td>
                    <td width="76%" height="404" valign="top"> 
                      <table width="95%" border="0" cellspacing="0" cellpadding="0" align="center">
                        <tr> 
                          <td class="pagetitle"><!-- #BeginEditable "page_title" -->Login:<!-- #EndEditable --></td>
                        </tr>
                        <tr> 
                          <td class="pagecontent" valign="top"><br>
                            <!-- #BeginEditable "page_content" --><br>
    <?
    if ($validate=="yes")
    {
        echo 
    $username;
        echo 
    "<br>";
        echo 
    $password;
        
    $sql="select * from members where username='$username' and password='$password'";
        
    $query=mysql_query($sql) or die("Could'nt get results");

        
    $num=mysql_numrows($query);

        
    //  Validating the username if $num=1 or giving invalid user message if
        //  $num==0

        
    if ($num==1)
        {
            
    setcookie("pstennis[username]",$username,date("Ymd")+365,"/",".ps-tennis.com",0);
            echo(
    "<center>Username $username logged in successfully!</center>");
        }

        elseif (
    $num==0)
        {
            
    errorMsg("Invalid username or password. Please <a href=\"login.php\"> click here </a> to login again");
            exit();    
        }
    }

    elseif (
    $validate=="" or $validate=="")
    {

    ?>
    <form name="form2" method="post" action="<?=$PHP_SELF?>">
                              <table width="70%" border="0" cellspacing="0" cellpadding="0" align="center" class="pagecontent">
                                <tr> 
                                  <td width="49%"><b>Username:</b></td>
                                  <td width="51%"> 
                                    <input type="text" name="username">
                                  </td>
                                </tr>
                                <tr> 
                                  <td width="49%"><b>Password:</b></td>
                                  <td width="51%"> 
                                    <input type="text" name="password">
                                  </td>
                                </tr>
                                <tr> 
                                  <td width="49%">&nbsp;</td>
                                  <td width="51%">
                                    <input type="hidden" name="validate" value="yes">
                                  </td>
                                </tr>
                                <tr> 
                                  <td colspan="2">
                                    <div align="center">
                                      <input type="submit" name="Submit" value="Submit">
                                    </div>
                                  </td>
                                </tr>
                              </table>
                            </form>
                            
    <?php
    }

    ?>


                            <!-- #EndEditable --> </td>
                        </tr>
                      </table>
                      <p>&nbsp;</p>
                    </td>
                  </tr>
                </table>
                <br>
                copyright notice goes here</td>
            </tr>
          </table>
        </td>
      </tr>
    </table>
    </body>
    <!-- #EndTemplate -->
    </html>

    Please help.


    -Omair
    36Host.com - $36/year web hosting [affiliates earn 30%]
    * Affordable Small Business Web Hosting since 2003! *
    "500mb space, 10gb bandwith, 50 pop/ftp accounts, php,
    mysql, pre-installed php scripts, 24/7 support & more...."



  2. #2
    SitePoint Zealot
    Join Date
    Nov 2001
    Location
    Earth
    Posts
    103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Howdy,

    Well the SQL looks rigth for checking the id/password. Are you storing the password as plain text or MD5's. You're checking the password as plain text, so I'll assume that's how it's stored.

    Can you post the layout of the users table (just the user-name and password columns). Could you have them defined too short and they are getting truncated?

    Frank
    http://www.serverexpert.com/ Discuss servers and the software that makes them work.
    http://www.webmasters-resources.com/ Resources for webmasters.

  3. #3
    SitePoint Guru
    Join Date
    Dec 2000
    Location
    Karachi, Pakistan
    Posts
    913
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually, there is nothing wrong in the code.

    It was all my stupidity that was causing problems. In the functions.php I had the username="" and password="" to connect to the database which caused the username and password to be changed to ="";

    Sorry for taking your time ffeingol.


    -Omair
    36Host.com - $36/year web hosting [affiliates earn 30%]
    * Affordable Small Business Web Hosting since 2003! *
    "500mb space, 10gb bandwith, 50 pop/ftp accounts, php,
    mysql, pre-installed php scripts, 24/7 support & more...."




Bookmarks

Posting Permissions

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