Jump to content

davidannis

Members
  • Posts

    627
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by davidannis

  1. The reason I used true for that condition is because if that is true, it changes it to that value. 

     

    all other conditions, false, set to the current dates value.

     

    I believe you are are correct about not converting it to a number and I am trying to match a string. I will test when I get home.

    The true checks not just that it is in the array but also that it is the same type (string, numeric, boolean) which is what I meant by "Try using in_array without the true to see if it is the type that is causing it to fail." The default is to not require that type match. No matter what you set that third parameter to the return value of the in_array() will be a boolean that is true if the value is in the array (and type is the same if you put ", true" at the end) or false if the value is not in the array.

  2. <input type="text" name="domain"><br>
    <input type="checkbox" value=".com" name="tld[]">.com<br>
    <input type="checkbox" value=".net" name="tld[]">.net<br>
    <input type="checkbox" value=".org" name="tld[]">.org<br>
    
    foreach($_POST['tld'] as $value){
    echo $_POST['domain'].$value."<br>\n";
    }
    

    will give you what you are looking for, output to the screen I believe. Of course, you need the rest of the HTML and the php, only provided the relevant pieces here.

  3. Please when you do

    var_dump($sql);
    

    as suggested, show us what you get.

     

    I am wondering if you are putting the correct value into the form that creates $_POST. Try using backticks in the form

     

    so $_POST['selform'] will contain

     `databasename`.`head`
  4. You need to sanitize $table (as previously discussed):

    $table = mysqli_real_escape_string($con,$_POST['selform']);
    

    The error is telling you that the query is failing. Perhaps $table doesn't have the value you expect. Try this:

    $sql = 'SELECT * FROM '.$table ;
    echo $sql.'<br>';
    $result = mysqli_query($con,$sql);
    
    
  5. An example might look like this:

    $lastpage=3;
    for ($counter = 1; $counter <= $lastpage; $counter++){
        echo "We're on page $counter <br>";
    }
    echo "done";
    

    which would output

    We're on page 1
    We're on page 2
    We're on page 3
    done
  6.  

    The more sophisticated examples, particularly those at stackoverflow, come closer but all of them seem to be critiqued by someone to the effect that they won't work in this or that particular situation.

    I'm not sure what situation they won't work in, but if you can't read the test cookie you wrote then you won't be able to read the preference cookie that you wrote. The browser doesn't know that the cookie is a test. I would just have the page after they set the preference cookie try to read the preference cookie and if it is not found tell them that you couldn't store their preferences for the next time and suggest that they may need to enable cookies.

  7. You get a bunch of data from PayPal via IPN. It comes as $_POST. First step is to sanitize that data and send it back to them via curl and they will verify that they sent it. (They provide sample code that does that). In their sample code the curl response is stored in $res. First you look for VERIFIED at the start of $res. If $res is not VERIFIED -- log the transaction and investigate. If the data you got is what they sent you can compare the various values to what you were expecting to get. I would look at payment_status to make sure it shows completed and mc_gross (how much the total transaction was for) mc_currency. I use a pass through variable invoice that I pass a unique value to them and they pass it back to match the transaction in my database. They warn you to do your DB updates after the curl verification because it times out pretty quickly if they send data and are not asked for a confirm. A complete list of all the data that they may send you is at https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNandPDTVariables/

  8. I don't think so. HTTP is stateless and you need to store the order someplace. The only other solution I can think of is to use an old pseudo random number generator that does not automatically seed and creates the same sequence if given the same seed and then have the teacher distribute the seed to the students. Hardly seems worth it to me, easier just to store the sequence. Also, storing it allows the teacher to have a copy of the questions in the correct order when reviewing it with students, etc. even if she reused the test.

×
×
  • 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.