Jump to content

uniflare

Members
  • Posts

    867
  • Joined

  • Last visited

Posts posted by uniflare

  1. If you want to update the form everyime a user changes something in the form, you can do this easiily with a submit form function in an onchange parameter on each input tag. This however could either a- get annoying having to wait for every single change to be checked and saved into the db.

     

    I would let them make all the changes they need, them have them tell the form "right, im done, save it please". This way, they make all the changes they need, and then they submit, php checks to make sure it all makes sense and if so saves it into the db.

     

    you can use ajax for this as well if you dont want to reload the 'whole' page, but this method is much easier and quicker using php to santize the variables etc, rather than relying on javascript/ajax code to make sure everything makes sense etc.

     

    hope this makes sense :P.

     

    PS: Basically all u need to do is keepo this form how it is, make a "Save Changes" button, rather than having a type='submit', have a type="button" with a onclick="ajax_function()";

     

    then ajax_function() would be an "ajax function" that would handle sending the form the php and php giving information as it is saved or rejected (sanitized).

    -- Not really that much code

  2. <?php
    
        $name = trim($_POST['name']);
        if (empty($name)) {
          $error['name'] = 'error';
        }
    
    ?>

     

    Try this instead:

    <?php
    
        if(!preg_match("/\A[a-z0-9_]{6,16}$/i",$_POST['name'])){
             $error['name'] = 'Must be Alphanumerical between 6 and 16 characters long.';
        }else{
             $name = $_POST['name'];
        }
    
    ?>

     

    \A = From the start of the string,

    [a-z0-9_] = match all characters in a single unbroken string, including underscores, that is between:

    {6,16} = minimum if 6 characters, maximum of 16 characters to be matched by [a-z0-9_]

    $ = until the very end of subject.

    ----

    As long as the whole subject from \A (start) to $ (finish) matches between 6-16 characters containing a-z, 0-9 or underscores.

     

    you can take out the _ in the pattern to disallow that too.

  3. Im not sure but ill give this a shot:

     

    You are probably getting all the deleted mail (simply in Trash Folder) in the "All Mail" tab, since its... ALL the mail.

     

    You are probably going to have to remove the messages from the trash folder;

     

    but to be honest, i'm not sure you really need this, personally: i would "move" all the matched mail to the Junk folder, that way the user can simply check through in case any important mail was mistakenly deleted.

     

    remember- php.net is extremely useful in these situations, me typing in php.net/imap gave me all the information i would need to do all this myself (having not done it before...ever)

     

    to get you started: http://uk2.php.net/manual/en/function.imap-mail-move.php

    Check through the list of functions on the left for others that may work, just try the examples, if they dont work try another :P.

  4. I dont get how "other people" can affect your unique internal data pointer unique to that variable in that script execution for the scripts executions query.

     

     

    Basically, to me uou are missing the "openticket" row on the list of rows you want to display. to display this do this:

    Reset the internal data pointer between mysql_fetch functions with mysql_Data_Seek.

     

    if you have code, give us; once youve tried my idea, and have code to support that youve tried my idea, i personally will move onto another idea. Until you try my idea, and show youve tried my idea, im not going to respond.

  5. if the top code was a.php, and the 2nd b.php, if i visited a.php it would send me to b.php and would then be sent to review.

     

    there must be  something else, try var dump the $_GET array:

     

    echo("<pre>"); var_dump($_GET); echo("</pre>");// DEBUG LINE TO SEE WHAT IS INSIDE _GET
    switch($_GET['ref']) {

  6. An index is a "Label" for an array item. eg;

     

    $test = Array(
       "this_is_an_index" => "this is a value",
       1 => "another value, 1 is the index"
    );

    so, echo($test['this_is_an_index']); would echo ("this is a value");

    echo($test[1]); // would echo ("another value, 1 is the index");,

    as you can see $test['password'] would give you an "Undefined Index", or "Array item does not exist".

     

     

     

    i believe $_POST['password'] doesnt exist, try using: (anywhere, it will show you the form data available to that page).

    echo("<PRE>"); var_dump($_POST); echo("</PRE>");

     

     

  7. In your code:

     

    This is giving you only the first row returned. Then moving the internal data pointer to row 2.

    	
    
    $opentick = mysql_fetch_array($gettickets);

     

    so this part will "start" on row 2, so it will start from the second result as the data pointer is on the 2nd row at this time.

    	
    
    while($tickets = mysql_fetch_array($gettickets)){

     

    PS: if i sound aggrevated, its only because u dint try it, u just shot it down. i know it will work! lol.

  8. Ok, you dont quite understand the way php gets results from mysql.

     

    PHP stores all of its rows returned by a query to an array, eg:

     

    Array(
       [0] => "row1",
       [1] => "row2",
       [2] => "row3"
    );

     

    Now, each time you call mysql_fetch_array(), you pick the "Next" array item, or row. (which is why you need a WHILE loop to get them all easily).

     

    eg;

     

    mysql_Fetch_Array() will give you array[0], or row 1.

    then next, mysql_Fetch_Array() will give you array[1], or row 2.

     

    if you were to use mysql_Data_seek($result,0);

     

    the next mysql_fetch_array would give you array[0], or row 1.

    then next, mysql_Fetch_Array() will give you array[1], or row 2.

    ...

     

    i hope this clears things up, its better to try things than to assume it wont work, cuz u never know. especially if you dont know.

  9. Edit: I do not need this function, uniflare. From what I've read this will tell you where your pointer is.

     

    Use it if you want, its up to you, it physically moves the data pointer, this is a quote from the page (u dint read this part obviously)

    mysql_data_seek() moves the internal row pointer of the MySQL result associated with the specified result identifier to point to the specified row number. The next call to a MySQL fetch function, such as mysql_fetch_assoc(), would return that row.

     

    I know what it does and why it does it. If you dont want to try my ideas then dont, but dont expect help if you wont listen.

     

    Did it work? or are you not going to try it?

     

  10. i believe you have ran into the mysql resource "pointer" problem. where you have a result set, $getticket, and you then use mysql_fetch_Array, which grabs 1 array and moves the "pointer" across 1 row (or down 1 row).

     

    so, you alwas miss that "top" result. you need to use this function if you doing stuff like that twice with one resource:

     

    mysql_Data_Seek();

    http://uk.php.net/manual/en/function.mysql-data-seek.php

     

    use it after your first fetch function, this will reset the "pointer caret" to the first row again.

  11. Naw don't really need security questions, its a form of another password, usually easier to guess :/ since ou know the "topic" of the question.... especially if its stuff like "whats your dogs name"!? like wth!? lol.

     

    Your current structure is fine, but i agree with genericnumber1: make sure people cant spam other email addresses. Once a request email has been sent say 3 times (email doesnt always arrive, every1 knows) - you should set a flag on the user profile showing that they need to log in with the new password before they can request another new password.

     

    Which is basically limiting the password forget request emails, to 3. Until the owner of the account logs back in.

     

    This would be extremely simple to implement, ou dont need any random q stuff. You should definietely have a way of entering a new password for themeselves or changing the current one in some "Account" Link.

     

    my 2 cents :P. its what i would do. Inactive accounts i would delete after a some months.

  12. Sounds to me your a little confused on how to deal with complicated database sctructures, have a look at the mysql tutorials on this site.

     

    -- If my assumption is correct, ou want to grab the comma sperated id list from mysql, into an array, like so:

     

    For a more direct answer, yes you can use explode. but not like that:

     

    like this:

    <?php
       // Grab that specific field
       $q = mysql_query("SELECT `id_field` FROM products WHERE id = '$products'");
       
       // Now loop each result (should only have one im assuming).
       while ($b = mysql_fetch_array($q)) {
             
             // Now each time we go through, we have a new "id_field" filled with id's.
             
             // Now we get an array of those id's
             $products = explode(',', $b['id_field']);
             
             // you would have to loop again (maybe a foreach $products As $productID)
             
          }
       ?>

     

    This is assuming you have lors of rows, and in each of these rows you have a column that keeps id's of other rows (maybe in other tables)?.

     

    IF you want information about those "other" rows, you will first have to grab the id's, sort through them, then make a massive! query (with each id, WHERE `id`='id_1' OR `id`='id_2' .... etc)

     

    This looks like a horrible way to sort your database.

     

    Maybe if you tell use what your database is to store we can help you make a much easier structure to maintain.

    -------------------

    i see, nm lol, you already made the list of id's :P

  13. dont echo anything bar the image, if there is an error, try to display an error image instead.

     

    Take a look at php.nets manual:

    php.net/imagecreatefrompng

     

    Example #1:

    <?php
    function LoadPNG($imgname)
    {
        /* Attempt to open */
        $im = @imagecreatefrompng($imgname);
    
        /* See if it failed */
        if(!$im)
        {
            /* Create a blank image */
            $im  = imagecreatetruecolor(150, 30);
            $bgc = imagecolorallocate($im, 255, 255, 255);
            $tc  = imagecolorallocate($im, 0, 0, 0);
    
            imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
    
            /* Output an error message */
            imagestring($im, 1, 5, 5, 'Error loading ' . $imgname, $tc);
        }
    
        return $im;
    }
    
    header('Content-Type: image/png');
    
    $img = LoadPNG('bogus.image');
    
    imagepng($img);
    imagedestroy($img);
    ?>
    

  14. Headers already sent; means the server has "Connected" with the client and the browser is now awaiting html/page code.

     

    ob_end_flush(); // i believe this is your culprit: http://uk2.php.net/ob_end_flush

     

    This function will send the contents of the topmost output buffer (if any) and turn this output buffer off. If you want to further process the buffer's contents you have to call ob_get_contents() before ob_end_flush() as the buffer contents are discarded after ob_end_flush() is called.

     

    So this function literally sends all the "captured" data to the browser.

     

    Any headers or functions that require headers (ie, cookies), MUST be called before any output (which is why you are using Output Buffering.)

  15. That code looks fine now, make sure you clear your cache etc.

     

    by following login.php code start->finish there is no "header" fuction being used at all so it if you really are visiting login.php then magical things are happening - the only explanation being the stored web cache.

  16. $consultsq1 = "SELECT * FROM `staffsched` WHERE `which_month`='".$curr_month."'";

     

    I believe its the order mysql is matching those rows. use ORDER BY, for which_month;

     

    $consultsq1 = "SELECT * FROM `staffsched` WHERE `which_month`='".$curr_month."' ORDER BY `which_month` DESC";

     

    hope this helps,

  17. I dont dabble in this myself, but i had a little look for you and should be interesting for you;

     

    http://theserverpages.com/php/manual/en/function.imagerotate.php

    http://uk3.php.net/imagerotate

     

    The comments on that page give lots of personal examples (i only scanned so i dont know the quality of the code). But it should give you some ideas, this is a quote:

    If you need a rotate function, ask your provider to install JPEGTRAN on the machine your server runs on and use the command line tool from your php application.

    JPEGTRAN is a *nix command, more information:

    http://linux.about.com/library/cmd/blcmdl1_jpegtran.htm

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