Jump to content

CroNiX

Staff Alumni
  • Posts

    1,469
  • Joined

  • Last visited

  • Days Won

    12

Posts posted by CroNiX

  1.  

    Give this a go :

     

    $name = $_REQUEST['applicant_name'] ;

    $address = $_REQUEST['applicant_address'] ;

    $headers = "MIME-Version: 1.0" . "\r\n";

    $headers .= "Content-type:text/plain;charset=iso-8859-1" . "\r\n";
    $headers .= "From: " . $name . "\r\n" ."Reply-To: " . $name . "\r\n" . 'X-Mailer: PHP/' . phpversion();
    $success = mail("deleted_for_public_posting_purposes", "Online Job Application", $address, $headers);

     

    For the $headers, don't you mean to use $address instead of $name? I assume $address is an email address and $name is a name like "Joe Blow". That might be why this didn't work to begin with.

  2. htusers is just a text file that contains a user:password on each line.

     

    user1:password

    user2:password2

     

    So all you'd need to do is load the htusers file in php, read line by line and explode on the : to separate the user from the password, and then store in mysql however you want.

  3. Because $res IS an array of all usernames, which is what your query asked for by using fetchAll(). So you'd need to iterate over that array.

    foreach($res as $user)
    {
      echo $user['username'] . "<br>";
    }
  4. Depends on what you need to search for, but let's say you want to search for the users last name.

     

    Create a form with an input for the last name. When submitting the form, just do a search for the last name in the db using WHERE lastname = 'lastname_from_form' to get an exact match, or WHERE lastname LIKE 'lastname_from_form%' to get all that start with lastname_from_form (the % at the end is a wildcard).

     

    Then display the list of matched users

  5. That's a lot of code to wade through, but here's how I'd generally do it:

     

    1) form is sent

    2) data is validated, images saved, etc

    3) Reshow form with data

    3a) When generating the FILE inputs, if one has a file already uploaded, don't show the FILE input for that one. Instead show a checkbox to delete the file and show the filename.

     

    So if 3 pdf's/whatever were uploaded, the first 3 spots where you'd normally see the upload button would instead have a checkbox. The other remaining 7 inputs would show the upload.

     

    Checking some or all of the checkboxes and resubmitting the form would delete/unlink() those files during step #1 above, and when the form is redisplayed, the upload slots would show up again in their place.

  6. There's not really enough info to answer the question.

     

    All the code above shows is incrementing a counter in $_SESSION.

     

    It doesn't show anything about what's in the cart. What data from the cart are you trying to save and what does it look like? What's the schema for the db that you want to add the cart data into?

  7. This topic is SOLVED!

     

    I was loking a way to mark it by myself, but without luck.  ::)

     

    Please, can any moderator mark this topic as SOLVED?

    There is a "Mark Solved" button on the lower-right of each post. Click that next to the post that was most helpful.

  8. Yes, you'd need a php powered pdf generator. There are many around, like FPDF, TCPDF and a few more main ones (google "php pdf"). It's also not easy to do and you'd have a lot of tweaking to your css to get them to display properly in a pdf document, since PDF's are of a fixed height/width. It won't be as easy as just saying "take the current HTML and put it in a PDF".

    • Like 1
  9. $image = $default_skin_url; //used as default
    if (isset($_GET['user'])) { //is the user set?
      $user = $_GET['user'];
      //Does the user image exist on site A?
      $site_a = "http://halcyon-pvp.fr/skins/$user.png";
      $site_b = "http://skins.minecraft.net/MinecraftSkins/$user.png";
     
      if (file_get_contents($site_a) !== FALSE) $image = $site_a;
      else if (file_get_contents($site_b) !== FALSE) $image = $site_b;
    }
     
    $skin = imagecreatefrompng($image);

    1) If image exists on site_a, it uses that.

    2) If image does not exist on site_a, it checks site_b. If it exists there, it uses that.

    3) If image does not exist on site_a or site_b, it uses the default.

  10. But you have a logic problem and you're essentially saying this:

     

     

    if ($something == 'a') {
      echo 'found in the IF';
    } else if ($something == 'a') {
      echo 'found in the elseif';
    }

     

    If something does == 'a', what will be echoed? It will never reach the elseif if something == 'a'.

  11. if (isset($_GET['user'])) {
     
    }
    elseif (isset($_GET['user'])) { //since this is checking the exact same thing as the first IF(), this will never get triggered since it's in the elseif() which will only happen if the first IF() isn't true, which it is
     
    }
  12. I believe you'd need to use register_shutdown_function() to capture FATAL errors, which are the most important to know about :) Otherwise fatal errors will crash the system and won't get reported by a custom error handler because PHP is done processing at that point since fatal errors kill the script right then and there so they can't be logged normally.

     

    http://stackoverflow.com/questions/4410632/handle-fatal-errors-in-php-using-register-shutdown-function

  13. No, like this

    if(!$mail->send()) {
        echo 'Message could not be sent.';
        echo 'Mailer Error: ' . $mail->ErrorInfo;
    } else {
    	echo 'Message has been sent';
    }
     
    }
    
    mysql_query("DELETE FROM alert WHERE idalert IN(".implode(",", $ids).")");
    print_r($ids);
    

    In you last post, neither example you showed was even running the query.  All you did was, again, define the sql string.

    I think actually you might only want to track the IDs that the email was successfully sent to, and delete only those. So build a new array of IDs to be deleted within the ELSE. Otherwise you won't be able to resend to people who the email wasn't successfully sent to the first time as they are now deleted from the db.

     

    Another thing to check before running the MySQL delete is whether the $IDs array contains any values, or there will be a mysql error if the array is empty.

  14. For one thing, if your host is named "myhost.com", you need to send email FROM someone@myhost.com.

     

    If the FROM in an email differs from the HOST, most ISPs will reject it outright or send it to spam.

     

    Email is extremely tricky and one of the most complex things in terms of getting high deliverability. You need things like PTR DNS records, Reverse DNS records, DKIM, your IP must have a good "reputation" and not be on any RBLs, etc. If you have critical emails that MUST get delivered, you should really look to using a service like SendGrid which will do all of that for you.

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