Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Posts posted by ginerjm

  1. Don't wrap the query parms in the single quotes.  Also when you use bindvalue (which I don't) the default type will be a string which you don't want for the age value. 

     

    This works much better for me:

    $stmt->execute(array('name'=>$_POST['name'],'age'=>$_POST['age']));
    

  2. So your returned value is False.  That implies that the execute failed.  Never write code that "does" something that could fail without checking the result.  Especially a class where you plan on using it a lot.  So - test the execute and display the error (on screen during development or in your error_log once in production).

  3. When you throw a bunch of class-related code at us and give us way too much to look at without fully understanding the goal, it makes us not want to help you.

     

    Try debugging each of your methods to be sure that they are doing EXACTLY what you expect.  Once you are happy with them, do the same debugging with your surrounding logic to be sure that you are giving those methods what they expect and that the returns are what you expect still.

     

    When you get down to one single point of contention - show us that roadblock and tell us what is not working.

  4. Your output seems to be exactly what you are echo-ing.  If you want it formatted, do it with your echo or simply add another echo to output a line break. (inside the loop).

     

    As for missing items and the limit 1 points - show us that code if you want to discuss it.

  5. What do you mean "how to display" your checkbox on a get.  The incoming query string will look like:  checkboxname=checkboxvalue.  Of course if you don't have an actual value= attribute on your checkbox tag (as I pointed out earlier), then 'checkboxvalue' may be non-existent in the string.

     

    A better checkbox tag:

    echo "<input type='checkbox' name='chkbox1' id='chkbox1' value='1'>  <label for='chkbox1'>Selection 1</label>"; 
    

     

    Here I assign a value of '1' to the choice of 'Selection 1'.  You can just as well use 'Selection 1' in your value attribute, but that is up to the situation you are in.

  6. That's not how you mix in your vars to the JS function.  You can't use php in a js function since one is client-side and the other is server-side.  Make you js function retrieve the values you want from the dom by using simple js things such as getElementById.  (google it).

     

    Ps - Is English not your normal language?  Cause if it is, how are you ever able to spell php functions correctly?

  7. Pdo does not have to be used as OOP.  I use it strictly in procedural mode and find it very easy to use.

     

    $q = "select * from (table) where key1= :mykeyvalue1";   // note use of : in the key argument here
    $qst = $pdo_conn->prepare($q);     // $pdo_conn is created in a separate piece of connect logic that one can easily write in an included module
    if (!qst)
        echo "error doing prepare";
    $qst->execute(array('mykeyvalue1'=>$key1));
    while ($row = $qst->fetch(PDO::FETCH_ASSOC))
    {
       (process the returned rows)
    }
    

     

    Hope this makes it clearer.

  8. With all that input I would not use a GET for my input.  Set your form method to be POST instead.

     

    Also - your checkboxes don't have a value clause which is usual.  Of course you still have to check if they are set but then you can simply use the value as the value to be saved.

     

    if (isset($_POST['checkbox1']))
        $checkbox1 = $_POST['checkbox1'];
    else
       $checkbox1 = 0;     // or whatever you want saved
    

  9. "Login system"?

     

    Is this something more than a simple form that asks for a user id and password?  I've not heard it referred to as a 'login system' before.  Normally it is simply the form and some logic and a db query to check the entries or to save them.

  10. 1 - create your text file and store it outside of your web-accessible tree for security purposes.

    2 - create a small php script that contains a function that has two arguments - user and password.

    3 - in this function open the text file and start a loop on it to read the lines one at a time. 

    4 - match the user and password argument against the contents of the current line you just read.  If it matches, set the cookie and return true from the function

    5 - if it doesn't match, read the next line from the text file and repeat step 4

    6 - if you reach the end of the file and exit the loop, return false.

  11. Maxdd - I rarely use oop.  Small projects, not enough repetition to warrant classes, use includes for standards pieces of code.

     

    Hansfore - function does stand out on the function header, but in use that word isn't obvious!  Of course, function names in php are case-insensitive so it doesn't matter but it's just one of my own conventions.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.