login page error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    login page error

    Hi I have a little problem with this page
    parse error: syntax error, unexpected T_VARIABLE in C:\xampp\htdocs\login.php on line 12
    can you guys maybe help me please

    PHP Code:
    <?php
    require_once("dbConfig.php");  //database connection

    // Catch field data
    $username $_POST['uname'];
    $password $_POST['pword'];
    $submitted $_POST['submitted'];

    if (
    $username $password)(
    //////////////////////////////////
    $query sprintf("SELECT * FROM users_cb where uname ='$username' and pword = '$password'")
    $result = @mysql_query($query);
    $rowAccount = @mysql_fetch_array($result);
    //////////////////////////////////
    )

    if (
    $rowAccount)(
                     
    echo 
    "The record exists so you can enter ";

    )elseif(
    $submitted)(

    echo 
    "You dont exist in the system so your npt getting in!";

    )

    ?>

    <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>

    <body>
    <form id="form1" method="post" action="<?php $_SERVER['PHP_SELF'];?>">
      <table width="200" border="2" align="center">
        <tr>
          <td>Username:</td>
          <td><label>
            <input name="uname" type="text" id="uname" maxlength="20" />
          </label></td>
        </tr>
        <tr>
          <td>Password</td>
          <td><label>
            <input type="text" name="pword" id="pword" />
          </label></td>
        </tr>
        <tr>
          <td colspan="2" align="center" valign="middle"><input name="submitted" type="hidden" id="submitted" value="1" />
            <label>
              <input type="submit" name="login" id="login" value="Login" />
          </label></td>
        </tr>
      </table>
    </form>
    </body>
    </html>

    #2
    surround the variables like this

    PHP Code:
     '".$var."' 
    than instead of this
    PHP Code:
     '$var' 
    so this is it implemented in your coding.

    PHP Code:
      <?php 
    require_once("dbConfig.php");  //database connection 
     
    // Catch field data 
    $username $_POST['uname']; 
    $password $_POST['pword']; 
    $submitted $_POST['submitted']; 
     
    if (
    $username $password)( 
    ////////////////////////////////// 
    $query sprintf("SELECT * FROM users_cb where uname ='".$username."' and pword = '".$password."'"
    $result = @mysql_query($query); 
    $rowAccount = @mysql_fetch_array($result); 
    ////////////////////////////////// 

     
    if (
    $rowAccount)( 
                      
    echo 
    "The record exists so you can enter "
     
    )elseif(
    $submitted)( 
     
    echo 
    "You dont exist in the system so your npt getting in!"
     

     
    ?> 
     
    <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <title>Untitled Document</title> 
    </head> 
     
    <body> 
    <form id="form1" method="post" action="<?php $_SERVER['PHP_SELF'];?>"> 
      <table width="200" border="2" align="center"> 
        <tr> 
          <td>Username:</td> 
          <td><label> 
            <input name="uname" type="text" id="uname" maxlength="20" /> 
          </label></td> 
        </tr> 
        <tr> 
          <td>Password</td> 
          <td><label> 
            <input type="text" name="pword" id="pword" /> 
          </label></td> 
        </tr> 
        <tr> 
          <td colspan="2" align="center" valign="middle"><input name="submitted" type="hidden" id="submitted" value="1" /> 
            <label> 
              <input type="submit" name="login" id="login" value="Login" /> 
          </label></td> 
        </tr> 
      </table> 
    </form> 
    </body> 
    </html>
    Last edited by crazybrumi; 31.12.09, 23:17.
    Want something coded email me at sales@webnwaphost.com for a prices.




    Comment


      #3
      nd as far as i see you are using () insead of {}

      PHP Code:
      foreach ($_SERVER as $server => $value)
      {
      echo 
      "$server is $value<br />";

      Comment


        #4
        I did they changes you guys told me but still the same error im not sure if I used the corect sign "|" in line nine but they say the T_Variable error is in line 12 anyway here is the edited script again:
        PHP Code:
          <?php 
        require_once("dbConfig.php");  //database connection 
         
        // Catch field data 
        $username $_POST['uname']; 
        $password $_POST['pword']; 
        $submitted $_POST['submitted']; 
         
        if (
        $username $password){ 
        ////////////////////////////////// 
        $query sprintf("SELECT * FROM users_cb where uname ='".$username."' and pword = '".$password."'"
        $result = @mysql_query($query); 
        $rowAccount = @mysql_fetch_array($result); 
        ////////////////////////////////// 

         
        if (
        $rowAccount){ 
                          
        echo 
        "The record exists so you can enter "
         
        )elseif(
        $submitted)( 
         
        echo 
        "You dont exist in the system so your npt getting in!"
         

         
        ?> 
         
        <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"> 
        <html xmlns="http://www.w3.org/1999/xhtml"> 
        <head> 
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
        <title>Untitled Document</title> 
        </head> 
         
        <body> 
        <form id="form1" method="post" action="<?php $_SERVER['PHP_SELF'];?>"> 
          <table width="200" border="2" align="center"> 
            <tr> 
              <td>Username:</td> 
              <td><label> 
                <input name="uname" type="text" id="uname" maxlength="20" /> 
              </label></td> 
            </tr> 
            <tr> 
              <td>Password</td> 
              <td><label> 
                <input type="text" name="pword" id="pword" /> 
              </label></td> 
            </tr> 
            <tr> 
              <td colspan="2" align="center" valign="middle"><input name="submitted" type="hidden" id="submitted" value="1" /> 
                <label> 
                  <input type="submit" name="login" id="login" value="Login" /> 
              </label></td> 
            </tr> 
          </table> 
        </form> 
        </body> 
        </html>

        Comment


          #5
          on the query line u forgot to close with ;

          Comment


            #6
            Thanks ori Solved my problems

            Comment


              #7
              K I added some sessions now I get error again
              Parse error: syntax error, unexpected T_VARIABLE in C:\xampp\htdocs\login.php on line 7

              PHP Code:
                <?php 
              require_once("dbConfig.php");  //database connection 
               
              session_start()

              // Catch field data 
              $username $_POST['uname']; 
              $password $_POST['pword']; 
              $submitted $_POST['submitted']; 
               
              if (
              $username $password){ 
              ////////////////////////////////// 
              $query sprintf("SELECT * FROM users_cb where uname ='".$username."' and pword = '".$password."'"); 
              $result = @mysql_query($query); 
              $rowAccount = @mysql_fetch_array($result); 

              ////////////////////////////////// 

               
              if (
              $rowAccount){ 
                                
              $_SESSION['id'] = $rowAccount['uname'];

              header("location:index2.php");
              exit;
               
              }elseif(
              $submitted){ 
               
              echo 
              "You dont exist in the system so your not getting in!"
               

               
              ?> 
               
              <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"> 
              <html xmlns="http://www.w3.org/1999/xhtml"> 
              <head> 
              <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
              <title>Untitled Document</title> 
              </head> 
               
              <body> 
              <form id="form1" method="post" action="<?php $_SERVER['PHP_SELF'];?>"> 
                <table width="200" border="2" align="center"> 
                  <tr> 
                    <td>Username:</td> 
                    <td><label> 
                      <input name="uname" type="text" id="uname" maxlength="20" /> 
                    </label></td> 
                  </tr> 
                  <tr> 
                    <td>Password</td> 
                    <td><label> 
                      <input type="text" name="pword" id="pword" /> 
                    </label></td> 
                  </tr> 
                  <tr> 
                    <td colspan="2" align="center" valign="middle"><input name="submitted" type="hidden" id="submitted" value="1" /> 
                      <label> 
                        <input type="submit" name="login" id="login" value="Login" /> 
                    </label></td> 
                  </tr> 
                </table> 
              </form> 
              </body> 
              </html>

              Comment


                #8
                session_start() needs a ; at the end of it

                session_start();

                please look at the last problem we solved for you it had same error and it near enuf was same fix.
                Want something coded email me at sales@webnwaphost.com for a prices.




                Comment


                  #9
                  PHP Code:
                  <?php 
                  session_start
                  ();
                  require_once(
                  "dbConfig.php"// database connection



                  if (! isset($_SESSION['id'])){

                  header("location:login.php");
                  exit;

                  }

                  $id $_SESSION['id'];

                  /////////////////////////////////////////////
                  $query sprintf("SELECT * FROM users_cb where uname ='$id'");
                  $result = @mysql_query($query);
                  $rowAccount = @mysql_fetch_array($result);
                  /////////////////////////////////////////////

                  ?>
                  <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
                  <html xmlns="http://www.w3.org/1999/xhtml">
                  <head>
                  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                  <title>Untitled Document</title>
                  </head>

                  <body>Welcome <?php echo $rowAccount('uname'];?>
                  </body>
                  </html>
                  Parse error: syntax error, unexpected T_IF in C:\xampp\htdocs\index2.php on line 7
                  Last edited by cobusbo; 01.01.10, 14:20.

                  Comment


                    #10
                    }else{
                    if($submitted){

                    echo "You dont exist in the system so your not getting in!";

                    } }
                    Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
                    Visit: WapMasterz Coming Back Soon!
                    _______
                    SCRIPTS FOR SALE BY SUBZERO
                    Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
                    FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
                    _______
                    Info & Tips
                    php.net
                    w3schools.com

                    Comment


                      #11
                      I had a space before <?php but its fixed im done with the script thanks to you guys and thnks for the patience
                      Last edited by cobusbo; 01.01.10, 15:26.

                      Comment

                      Working...
                      X