Jump to content

jimfog

Members
  • Posts

    1,803
  • Joined

  • Last visited

Posts posted by jimfog

  1. I found this code in tha php manual, the link is here...http://www.php.net/manual/en/filter.filters.sanitize.php:

    array_filter($_POST, 'trim_value');    // the data in $_POST is trimmed$postfilter =    // set up the filters to be used with the trimmed post array    array(            'user_tasks'                        =>    array('filter' => FILTER_SANITIZE_STRING, 'flags' => !FILTER_FLAG_STRIP_LOW),    // removes tags. formatting code is encoded -- add nl2br() when displaying            'username'                            =>    array('filter' => FILTER_SANITIZE_ENCODED, 'flags' => FILTER_FLAG_STRIP_LOW),    // we are using this in the url            'mod_title'                            =>    array('filter' => FILTER_SANITIZE_ENCODED, 'flags' => FILTER_FLAG_STRIP_LOW),    // we are using this in the url        );

    What I cannot find to the above code -in the one assigned in the postfilter variable specifically- the reference to the $_POST array.

     

    The comment besides the postfilter says..."to be used with the trimmed post array".

    I do not see any reference to that array in the code below.

     

    As you might guessed I am not so experienced with arrays that's why I need some help here.

     

  2. I am making a profile page where there is a form and the user just has the option of updating/deleting his data...phone,address,name etc.

     

    I use ajax requests with cache:true. I am using cache:true cause the form is something(not my just form...any form) is NOT updated every few seconds.

     

    But I do not know if setting cache:true is the correct choice for a form.

    What do you think?

  3.  

     

    You asked if your code does two things

    1) deletes a ("remember me") cookie, in this case called "cookiename"

    2) kills a session

     

    So yes, presumably, to both things.

     

     

    I am covered now... thanks. The above is what I was expecting to hear...that I accomplish both things.

  4. Ι used decimal(3.2) but I noticed that it cannot accept 10 or 20 for example....why that? I thought the 3 means 3 digit number MAX.

     

    I receive a message saying out of range value....

  5. yes, remember me cookie and session cookie, both.

    I assume I delete the remember me cookie by setting it expire to the past and I delete the session cookie by unsetting the session.

     

    Am I saying it correctly? I think my function addresses both of these issues.

  6. $arr[]='foo';

    I still cannot make it work...overwriting takes place still(despite trying the above). Here is a cleaner version of the code where I have stripped out unnecessary things like the query itself so that we can focus better on the while loop:

    The function:

     function get_services($connection,$email) {     $serviceslist=array();    .....            {                while ($services=$result->fetch_object()) {//άραγε πότε χρησιμοποιώ το                    $serviceslist['services']=$services->servicename;                       var_dump($serviceslist);                       }        } return $serviceslist;         } 

    And here is the code which calls the function:

    $services=get_services($conn,$_SESSION['valid_user']);                               echo $services['services']; 

    Instead the browser echoing 2 rows I get 1...the overwriting problem takes place.

  7. I am constructing a logout function...for what I have doubts though is the implementation. This function tries to address 2 different scenarios. There is a cookie in the user's PC(remember me feature) and the second scenario is that there is no remember me cookie in the client.

     

    I do not know though if I am doing it the right ways...here is the code:

       function logout($connection)    {     if (isset($_COOKIE['cookiename'])||isset($_SESSION['valid_user']))       {    $username = $_SESSION['valid_user'];   setcookie('cookiename',"", time() - 3600);   unset($_SESSION['valid_user']);   session_destroy();      $result = $connection->query("DELETE FROM session WHERE username='".$username."'");    if(!$result)      {echo 'deletion failed';      return false;      }    }        }
  8. You overwrote the array with something else.

     

    Typing $a = array() and then $a = 5 won't give you an array with "5" in it. It will just be "5". The assignment operator "=" overwrites anything that was previously in the variable.

    Αnd what is the solution to it?

  9. I cannot make it work. I did what you said but obviously there is something I am doing wrong:

    function get_services($connection,$email) {     $serviceslist=array();     $connection->set_charset("utf8");             $result = $connection->query('                                select servicename                 from business_users,buser_services,services,users                 where users.email="'.$email.'"                 and users.user_ID=business_users.crID                 and business_users.crID=buser_services.buserID                 and buser_services.serviceID=services.serviceID;                ');        if(!$result)        {return false;}        elseif($result ->num_rows>0)            {                while ($services=$result->fetch_object()) {//άραγε πότε χρησιμοποιώ το                    $serviceslist=$services->servicename;                                    }                       }                    return $serviceslist;         }

    As you above, in the beginning of the function I declare servicelist as an array but the results are the same as before.One row gets returned.

  10. I am having difficulty getting rows out of the db. The code is in a function and the while loop is correct(you will see in a while), the problem what is returned from the function.

     

    First, the code:

    function get_services($connection,$email) {       $connection->set_charset("utf8");             $result = $connection->query('                                select servicename                 from business_users,buser_services,services,users                 where users.email="'.$email.'"                 and users.user_ID=business_users.crID                 and business_users.crID=buser_services.buserID                 and buser_services.serviceID=services.serviceID;                ');        if(!$result)        {return false;}        elseif($result ->num_rows>0){    while ($services=$result->fetch_object()) {//άραγε πότε χρησιμοποιώ το        $serviceslist=$services->servicename;          var_dump($serviceslist);        }}        return $serviceslist;        }

    var_dump gives me 2 rows, stored in the servicelist variable...so this is OK.

    The problem is that when I call the function, only one row gets returned.

     

    Here is the code that calls the function:

    $services=get_services($conn,$_SESSION['valid_user']);                               echo $services;

    in the above code...only one row gets echoed in the browser.

    What am I doing wrong?

  11. I have set up a transaction in which 2 queries are performed, 2 inserts having to do with user registration.

    Suppose that one of the queries fails, how am I going to learn which one failed?

     

    Can exceptions help me here?

  12. I intend using a lot at a website I am building but given the fact that some browsers do not support it completely yet is there a way to use a fallback mechanism-progressive enhancement is the correct term.

     

    I mean, like when js is disables and we make the site run solely on PHP.

     

    Is there anything similar we can do with css3?

  13. I have set up a script which accepts ajax requests regarding the deletion of an account.

    The first request goes to delete the account and if the user has data left in his/her account gets a warning.

     

    If he still wants to go for the deletion the second ajax request is sent at which point the problems begin.

    The script has a variable in it which is NEEDED for the second request.

     

    So when the first request is on its way I get Notice: Undefined index: deletestate...

     

    Here is the script:

     

    <?php session_start();  require 'admin_db_code.php';//ένα db connect είναι εδώ$sessionml=$_SESSION['valid_user'];$delpass=$_POST['delpass'];$deletestate=$_POST['deletestate'];if($deletestate==1)    {        }  $output=delete_account($conn,$delpass,$sessionml); if($output=='0') {$success='0';} elseif($output=='1') {logout($conn); $success='1';} elseif($output=='2') {$success='2';} elseif($output=='3') {$success='3';} elseif($output=='4') {$success='4';} echo $success;    ?>

    delete_account is suppose to be run on the first request-at which case we have the warning.

    But it does not since I get the notice for $deletestate...this variable gets sent with SECOND request at which will have no problem but unfortunately we cannot get at this step for the reasons already explained.SO THE MOMENT OF THE FIRST AJAX REQUEST $deletestate IS UNDEFINED.

     

    What can I do? I need this variable. It contains the answer of the user "yes delete my account" but it gets sent only in the second request.

     

  14. After the queries are finished, should I always use autocommit(TRUE)?

    Or the commit method is sufficient to turn on again the autocommit feature of the db? It is not clear to me.

     

    Provided the fact of course that I do want to set it that way.

  15. I intend installing xdebug 2.2.2 but I cannot understand which files to download from the ones listed here http://xdebug.org/download.php

     

    By looking at the output of phpinfo() I see that I have php 5.4.4 VC9 x86 architecture-I suppose that means downloading the 32 bit version.

     

    I see also that there are 2 types of xdebug, non-TS and TS,what is the difference?

  16. I am building a form like the one found in the edit profile page of facebook...where a distinctive characteristic of it is that

    by opening a segment, another closes.

     

    For example, if the BAsic Information section is open, it automatically closes if I choose to open the Living section

     

    I am trying to accomplish that manually but I am wondering if there is a plugin that can make my life easier.

  17. Ι think this code must be OK now...I am going to test it either way:

       $connection->autocommit(FALSE);      $result1 =$connection->query("insert into users values (NULL,'" .$name. "','" .$lastname . "','".$email."','". $passwd."','". $hash."','4')");      $result2=$connection->query("insert into business_users values('".$connection->insert_id."','".$address."' , '".$url ."','".$phone. "','".$city. "','".$municipality. "','".$buztype. "')");            if(!$result||!$result2)      {$connection->rollback();       $connection->autocommit(TRUE);       echo 'transaction failed';       return false;      }      else          {          $connection->commit();          $connection->autocommit(TRUE);          }
  18. The problem now though, it is that the hidden element occupies the space in the form-it is seen as large empty space.

    The goal is that the space is NOT occupied.

     

    I FIXED..almost, if there is a problem I will repost.

×
×
  • Create New...