PHP Login System with Admin Features

This forum was created to talk about the PHP Login System with admin features created by jpmaster77 on evolt's website


    query question

    Share
    avatar
    intothefantasy

    Number of posts : 37
    Registration date : 2009-04-11

    query question

    Post  intothefantasy on Wed Apr 29, 2009 8:17 am

    i am trying to play around with the script and i wanted to make more than 1 query...

    is like i wanna try something like this...
    Code:
    function addNewUser($username, $password, $email){
          $time = time();
          /* If admin sign up, give admin user level */
          if(strcasecmp($username, ADMIN_NAME) == 0){
            $ulevel = ADMIN_LEVEL;
          }else{
            $ulevel = USER_LEVEL;
          }
          $q = "INSERT INTO ".TBL_USERS." VALUES ('$username', '$password', '0', $ulevel, '$email', $time)";
          return mysql_query($q, $this->connection);

      }

    top here is the code for register...of course from the code above shows that the registered details will be insert in to users table...now i wan to insert more than 1 table...which mean in the same time i wanna insert those details in users table and another test table which i have duplicate out...i keep trying to create a new $z and not having any result...wat i doin here is that...i wanna make a big register form which has alot of fields...and some of the fields i wanted it to store userid in another table...
    avatar
    Linchpin311

    Number of posts : 220
    Age : 32
    Localisation : Long Island
    Registration date : 2007-05-14

    Re: query question

    Post  Linchpin311 on Wed Apr 29, 2009 5:09 pm

    just to make sure we are on the same page here...

    you want to alter the register.php page and have a lot of fields? you then want to insert some of those fields into one table and insert other fields into another table? the two tables are not identical, correct?

    if so, you can just do two queries and execute them one right after the other. let me know if i am understanding you correctly.


    _________________
    in the end, the universe tends to unfold as it should...

    Also note that it is your responsibility to die() if necessary.
    avatar
    intothefantasy

    Number of posts : 37
    Registration date : 2009-04-11

    Re: query question

    Post  intothefantasy on Thu Apr 30, 2009 5:15 am

    i tried something like this and says i fail to register but still i saw the value has inserted to both tables

    Code:
    function addNewUser($username, $password, $email){
          $time = time();
          /* If admin sign up, give admin user level */
          if(strcasecmp($username, ADMIN_NAME) == 0){
            $ulevel = ADMIN_LEVEL;
          }else{
            $ulevel = USER_LEVEL;
          }
          $q = "INSERT INTO ".TBL_USERS." VALUES ('$username', '$password', '0', $ulevel, '$email', $time)";
          $result1 = mysql_query($q, $this->connection);
          $z = "INSERT INTO ".TBL_TEST." VALUES ('$username', '$password', '0', $ulevel, '$email', $time)";
          $result2 = mysql_query($z, $this->connection);
          return 0;

      }
    done something like this...can insert the values to 2 table...but problem is it will direct me to a fail register message....is know is the return problem...can anyone help me fix this?
    avatar
    Linchpin311

    Number of posts : 220
    Age : 32
    Localisation : Long Island
    Registration date : 2007-05-14

    Re: query question

    Post  Linchpin311 on Thu Apr 30, 2009 10:23 pm

    well you are returning 0 when the original function calls to return the actual query. try changing
    Code:
          $q = "INSERT INTO ".TBL_USERS." VALUES ('$username', '$password', '0', $ulevel, '$email', $time)";
          $result1 = mysql_query($q, $this->connection);
          $z = "INSERT INTO ".TBL_TEST." VALUES ('$username', '$password', '0', $ulevel, '$email', $time)";
          $result2 = mysql_query($z, $this->connection);
          return 0;
    to
    Code:
          $z = "INSERT INTO ".TBL_TEST." VALUES ('$username', '$password', '0', $ulevel, '$email', $time)";
          mysql_query($z, $this->connection);

          $q = "INSERT INTO ".TBL_USERS." VALUES ('$username', '$password', '0', $ulevel, '$email', $time)";
          return mysql_query($q, $this->connection);
    let me know if changing this around gets things working for you.


    _________________
    in the end, the universe tends to unfold as it should...

    Also note that it is your responsibility to die() if necessary.
    avatar
    sketchone

    Number of posts : 2
    Registration date : 2011-03-03

    Re: query question

    Post  sketchone on Fri Jun 24, 2011 7:59 pm

    can u show how to do this step to step, i was trying to do this myself with two different registered froms, but one registration has more fields than the other because its for two different types of accounts. can you help me with this also please ?

    Sponsored content

    Re: query question

    Post  Sponsored content


      Current date/time is Tue Sep 19, 2017 9:34 am