SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 30 of 30

Thread: PHP noob

  1. #26
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    The point which I omitted to make after my short missal, was that if you have taken the trouble to do some cursory checking on the client using JS and you labelled your form up correctly - in order to detect whether the form was sent - you could simply check for the absence of one of your mandatory fields.
    PHP Code:
    if( isset($_POST) && !isset($_POST['name']) ){

    // the form was sent but was subverted somehow
    // now fail early and tidily here without wrapping
    // your entire logic in an if(){}else{} clause

    header('Location: backtotheform.php');
    exit();
    }

    // now do your security filtering ... which may in turn
    // end up with you aborting when a filter fails... 

  2. #27
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by deathshadow60 View Post
    Check your php.log
    I don't have a php.log (I'm on Linux).

    I checked my apache error log, there was nothing about any empty() calls on undefined variables/ indexes.

    I even checked my syslog, again there was nothing about any empty() calls on undefined variables/ indexes.




    Here's my test script:

    PHP Code:
    <?php
    error_reporting
    (-1);
    ini_set('display_errors''On');

    $myVar = array();

    var_dump(empty($myVar['test']));
    var_dump(empty($non_existant_variable));
    ?>
    Here's the output:

    Code:
    boolean: true
    boolean: true

  3. #28
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,067
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by deathshadow60 View Post
    Check your php.log
    I'm running with error_reporting -1 here, and when I execute this script

    PHP Code:
    <?php
    var_dump 
    (empty($var1));
    if (
    $var2==2) echo 'Hi!';
    I get

    Code:
    boolean true
    
    ( ! ) Notice: Undefined variable: var2 in <snip/>\empty.php on line 3
    Call Stack
    #	Time	Memory	Function	Location
    1	0.0012	368312	{main}( )	..\empty.php:0
    So, empty does not an give a notice, error, whatever.

    As for the log

    Code:
    [Wed Aug 31 14:52:48 2011] [error] [client <snip/>] PHP Notice:  Undefined variable: var2 in <snip/>\\empty.php on line 3
    [Wed Aug 31 14:52:48 2011] [error] [client <snip/>] PHP Stack trace:
    [Wed Aug 31 14:52:48 2011] [error] [client <snip/>] PHP   1. {main}() <snip/>\\empty.php:
    Nothing about the empty call in there either.
    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  4. #29
    Non-Member bronze trophy
    Join Date
    Nov 2009
    Location
    Keene, NH
    Posts
    3,760
    Mentioned
    23 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Cups View Post
    this is of course dead easy to subvert (turn JS off, for example).
    Or bots that don't give a flying fig what's actually on your HTML page for code, and just use a vague facsimile of your form to try and mass-submit.

    ... which is where a LOT of forms fail miserably.

  5. #30
    SitePoint Zealot
    Join Date
    Feb 2011
    Location
    Colorado, USA
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Everthing is now working thanks again everyone.

    I have one more issue I would like to get worked out. I have never joined two tables and am not sure how I would make this work. I have two tables in mysql one named "log" and the other "admin_log"."Log" has 5 columns (name, pin, adults, kids, time_in) and "admin_log" has 6 columns (name, pin, adults, kids, time_in, time_out). When a user signs in how can I make it update both tables with only (name, pin, adults, kids, time_in) being affected in admin_log and then time_out only when the user signs out. I want all the data backed up in this admin log so we can go back and view all records at the end of the day. And the way I have it set up now is to delete the row in "log" when a user clocks out. So I never have two names in the database at the same time. Any ideas or an easier way to do this will be greatly appreciated.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •