php question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • mmcgahy
    Private First Class

    • Feb 2008
    • 7

    php question

    I keep geing an error on a log in script I am trying to execute-

    Parse error: syntax error, unexpected '}' in /home/llllqubw/public_html/aftersolutions/register.php on line 53



    - with the following script, line 53 is noted in the script, can someone help, new to php.
    <?
    session_start();
    require ("dbts_asregister_config.php");
    $username = $_SESSION[username];
    $password = $_SESSION[password];
    if ($dbts_username != $username or $dbts_password != $password){
    $message = "Incorrect loggin!";
    header("Location: dbts_users_loggin.php");
    }
    Line 53
    $db = mysql_connect($db_host, $db_users, $db_password);
    if ($db == FALSE)
    die ("Connection Error. Please check parameters in the file config.php");
    mysql_select_db($db_name, $db)
    or die ("Database Selection Error. Please check parameters in the file config.php");
    ?>
    <?php


    //This code runs if the form has been submitted
    if (isset($_POST['submit'])){
    }
    //This makes sure they did not leave any fields blank
    if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] ) {
    die('You did not complete all of the required fields');
    }
    // checks if the username is in use
    if (!get_magic_quotes_gpc()) {
    $_POST['username'] = addslashes($_POST['username']);
    }
    $usercheck = $_POST['username'];
    $check = mysql_query("SELECT username FROM users WHERE username = '$usercheck'")
    or die(mysql_error());
    $check2 = mysql_num_rows($check);
    //if the name exists it gives an error
    if ($check2 != 0) {
    die('Sorry, the username '.$_POST['username'].' is already in use.');
    }
    // this makes sure both passwords entered match
    if ($_POST['pass'] != $_POST['pass2']) {
    die('Your passwords did not match.');
    }
    // here we encrypt the password and add slashes if needed
    $_POST['pass'] = md5($_POST['pass']);
    if (!get_magic_quotes_gpc()) {
    $_POST['pass'] = addslashes($_POST['pass']);
    $_POST['username'] = addslashes($_POST['username']);
    }
    // now we insert it into the database
    $insert = "INSERT INTO users (username, password)
    VALUES ('".$_POST['username']."', '".$_POST['pass']."')";
    $add_member = mysql_query($insert);
    ?>

    <h1>Registered</h1>
    <p>Thank you, you have registered - you may now login</a>.</p>
    <?php
    }
    else
    {
    ?>

    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    <table border="0">
    <tr><td>Username:</td><td>
    <input type="text" name="username" maxlength="60">
    </td></tr>
    <tr><td>Password:</td><td>
    <input type="password" name="pass" maxlength="10">
    </td></tr>
    <tr><td>Confirm Password:</td><td>
    <input type="password" name="pass2" maxlength="10">
    </td></tr>
    <tr><th colspan=2><input type="submit" name="submit" value="Register"></th></tr> </table>
    </form>
    <?php
    }
    ?>
    I would greatly appreciate any help thank you
  • Watdaflip
    Major General

    • Sep 2005
    • 2116

    #2
    Re: log in php problem

    Will you post the complete script, that error can be caused by a mistake before or after line 53

    Register/Login Script
    Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

    Comment

    • mmcgahy
      Private First Class

      • Feb 2008
      • 7

      #3
      Re: log in php problem

      Here is a copy of the whole page - thank you



      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
      <html>
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
      <title>Untitled Page</title>
      <meta name="GENERATOR" content="Created by BlueVoda">
      </head>
      <body bgcolor="#FFFFFF" text="#000000">
      <div id="bv_" style="position:absolute;left:0px;top:0px;width:12 72px;height:1401px;z-index:0" align="left">
      <img src="bv01995.gif" id="Shape2" align="top" alt="" border="0" width="1272" height="1401"></div>
      <img src="recruitmentblank (1020 x 222).jpg" id="Image2" alt="" align="top" border="0" width="1020" height="222" style="position:absolute;left:127px;top:42px;width :1020px;height:222px;z-index:1">
      <div id="bv_" style="position:absolute;left:339px;top:98px;width :449px;height:24px;z-index:2" align="left">
      <font style="font-size:21px" color="#000000" face="Arial"><b>Job Postings * Resume/Application Viewing</b></font></div>
      <div id="bv_" style="position:absolute;left:334px;top:133px;widt h:451px;height:48px;z-index:3" align="left">
      <font style="font-size:21px" color="#000000" face="Arial"><b>Recruitment Solutions * Retention Strategies</b></font></div>
      <div id="bv_" style="position:absolute;left:351px;top:171px;widt h:417px;height:24px;z-index:4" align="left">
      <font style="font-size:21px" color="#000000" face="Arial"><b>Career Counseling * Education * Training</b></font></div>
      <div id="bv_" style="position:absolute;left:149px;top:259px;widt h:975px;height:36px;background-color:#FF04FF;z-index:5" align="left">
      <table width="100%" border="5" cellpadding="1" cellspacing="3" bordercolor="#0000FF" id="Table2">
      <tr>
      <td align="left" valign="top" width="108" height="20">&nbsp;</td>
      <td align="left" valign="top" width="116" height="20">&nbsp;</td>
      <td align="left" valign="top" width="114" height="20">&nbsp;</td>
      <td align="left" valign="top" width="108" height="20">&nbsp;</td>
      <td align="left" valign="top" width="152" height="20">&nbsp;</td>
      <td align="left" valign="top" width="108" height="20">&nbsp;</td>
      <td align="left" valign="top" width="108" height="20">&nbsp;</td>
      <td align="left" valign="top" width="124" height="20">&nbsp;</td>
      </tr>
      </table></div>
      <div id="bv_" style="position:absolute;left:143px;top:373px;widt h:834px;height:480px;z-index:6" align="left">
      <?
      session_start();
      require ("dbts_asregister_config.php");
      $username = $_SESSION[username];
      $password = $_SESSION[password];
      if ($dbts_username != $username or $dbts_password != $password){
      $message = "Incorrect loggin!";
      header("Location: dbts_users_loggin.php");
      }
      $db = mysql_connect($db_host, $db_users, $db_password);
      if ($db == FALSE)
      die ("Connection Error. Please check parameters in the file config.php");
      mysql_select_db($db_name, $db)
      or die ("Database Selection Error. Please check parameters in the file config.php");
      ?>
      <?php


      //This code runs if the form has been submitted
      if (isset($_POST['submit'])){
      }
      //This makes sure they did not leave any fields blank
      if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] ) {
      die('You did not complete all of the required fields');
      }
      // checks if the username is in use
      if (!get_magic_quotes_gpc()) {
      $_POST['username'] = addslashes($_POST['username']);
      }
      $usercheck = $_POST['username'];
      $check = mysql_query("SELECT username FROM users WHERE username = '$usercheck'")
      or die(mysql_error());
      $check2 = mysql_num_rows($check);
      //if the name exists it gives an error
      if ($check2 != 0) {
      die('Sorry, the username '.$_POST['username'].' is already in use.');
      }
      // this makes sure both passwords entered match
      if ($_POST['pass'] != $_POST['pass2']) {
      die('Your passwords did not match.');
      }
      // here we encrypt the password and add slashes if needed
      $_POST['pass'] = md5($_POST['pass']);
      if (!get_magic_quotes_gpc()) {
      $_POST['pass'] = addslashes($_POST['pass']);
      $_POST['username'] = addslashes($_POST['username']);
      }
      // now we insert it into the database
      $insert = "INSERT INTO users (username, password)
      VALUES ('".$_POST['username']."', '".$_POST['pass']."')";
      $add_member = mysql_query($insert);
      ?>

      <h1>Registered</h1>
      <p>Thank you, you have registered - you may now login</a>.</p>
      <?php
      }
      else
      {
      ?>

      <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
      <table border="0">
      <tr><td>Username:</td><td>
      <input type="text" name="username" maxlength="60">
      </td></tr>
      <tr><td>Password:</td><td>
      <input type="password" name="pass" maxlength="10">
      </td></tr>
      <tr><td>Confirm Password:</td><td>
      <input type="password" name="pass2" maxlength="10">
      </td></tr>
      <tr><th colspan=2><input type="submit" name="submit" value="Register"></th></tr> </table>
      </form>
      <?php
      }
      ?> </div>
      </body>
      </html>

      Comment

      • Watdaflip
        Major General

        • Sep 2005
        • 2116

        #4
        Re: log in php problem

        It should be this line

        PHP Code:
         if (isset($_POST['submit'])){

        Make this
        PHP Code:
        if (isset($_POST['submit'])){ 

        Register/Login Script
        Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

        Comment

        • mmcgahy
          Private First Class

          • Feb 2008
          • 7

          #5
          Re: log in php problem

          Page came up with my banner but with no register form and new errors, I appreciate all your help on this, Im so tired of looking at this that I think its time to relax, and relook it tomorrow, I appreciate your help and I owe you one.







          Page came up wWarning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/llllqubw/public_html/aftersolutions/register.php:10) in /home/llllqubw/public_html/aftersolutions/register.php on line 34

          Warning: Cannot modify header information - headers already sent by (output started at /home/llllqubw/public_html/aftersolutions/register.php:10) in /home/llllqubw/public_html/aftersolutions/register.php on line 40

          Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'llllqubw'@'localhost' (using password: YES) in /home/llllqubw/public_html/aftersolutions/register.php on line 43
          Connection Error. Please check parameters in the file config.phpith my banner put no register form, new errors show-

          Comment

          • Watdaflip
            Major General

            • Sep 2005
            • 2116

            #6
            Re: log in php problem

            In this section of code
            [php]
            <?
            session_start();
            require ("dbts_asregister_config.php");
            [/php

            move this code

            PHP Code:
            session_start(); 
            And place it at the very top. So the top will be
            PHP Code:
            <? session_start(); ?>
            <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
            As far as the database connection make sure your username and password are correct, and that the username has access to the database

            Register/Login Script
            Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

            Comment

            • mmcgahy
              Private First Class

              • Feb 2008
              • 7

              #7
              Re: log in php problem

              same problem, I copied my config file eliminating usernames and passwords so you can see a copy

              <?
              $dbts_username="username";
              $dbts_password="password";
              $dbts_ownersite="http://www.aftersolutions.com";
              $dbts_owneremail="info@aftersolutions.com";
              $db_host="localhost";
              $db_name="database_name";
              $db_user="databease_username ";
              $db_password="database_password";
              ?>

              Again, thanks for the help, i owe you big time

              Comment

              • mmcgahy
                Private First Class

                • Feb 2008
                • 7

                #8
                Re: log in php problem

                Skip last message, sorry system was a little slow moving along, have 2 new error messages:

                Warning: Cannot modify header information - headers already sent by (output started at /home/llllqubw/public_html/aftersolutions/register.php:11) in /home/llllqubw/public_html/aftersolutions/register.php on line 41

                Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'llllqubw'@'localhost' (using password: YES) in /home/llllqubw/public_html/aftersolutions/register.php on line 44
                Connection Error. Please check parameters in the file config.php



                again thank you

                Comment

                • Watdaflip
                  Major General

                  • Sep 2005
                  • 2116

                  #9
                  Re: log in php problem

                  Sorry didn't tell you the right thing to move (at least completely)

                  I assume you made the change so your code should have
                  PHP Code:
                  <? session_start(); ?>
                  at the top, replace that code with this code, which you need to move up from where it currently is
                  PHP Code:
                   <? 
                  session_start();
                  require ("dbts_asregister_config.php");
                  $username = $_SESSION[username];
                  $password = $_SESSION[password];
                  if ($dbts_username != $username or $dbts_password != $password){
                  $message = "Incorrect loggin!";
                  header("Location: dbts_users_loggin.php");
                    }
                  $db = mysql_connect($db_host, $db_users, $db_password);
                  if ($db == FALSE)
                  die ("Connection Error. Please check parameters in the file config.php");
                  mysql_select_db($db_name, $db)
                  or die ("Database Selection Error. Please check parameters in the file config.php");
                  ?>
                  And make sure you remove that code from where it is

                  Register/Login Script
                  Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

                  Comment

                  Working...
                  X