Jump to content

Kristoff1875

Members
  • Posts

    242
  • Joined

  • Last visited

Posts posted by Kristoff1875

  1. As shown above, i'm using this to call the page with the email:

     

    <?
    // Connects to your Database
    mysql_connect("localhost", "***", "***") or die(mysql_error());
    mysql_select_db("***") or die(mysql_error());
    $data = mysql_query("SELECT * FROM completed WHERE followupsent='0000-00-00 00:00:00' AND DATE(valuesent) < DATE_SUB( NOW(), INTERVAL 7 DAY )")
    or die(mysql_error());
    
    while($info = mysql_fetch_array( $data ))
    {
    $id = $info['id'];
    header ("Location: followupemailauto.php?id=$id");
    }
    ?>
    

     

    Then on "followupemailauto.php" :

     

    <?
    
    $id = $_GET['id'];
    $pagefrom = $_SERVER['HTTP_REFERER'];
    // . (!empty($info['contactother']) ?
    
    // Connects to your Database
    mysql_connect("localhost", "***", "***") or die(mysql_error());
    mysql_select_db("***") or die(mysql_error());
    $data = mysql_query("SELECT * FROM completed WHERE id='$id'")
    or die(mysql_error());
    
    
    if($info = mysql_fetch_array( $data ))
    if ($info['valuation'] != ""){
    $body='***email content***';
    
    $subject = 'Subject';
    $message = $body;
    
    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'From: **** <noreply@****.com>' . "\r\n";
    mail( $info['email'],$subject,$message,$headers );
    mysql_connect("localhost", "***", "***") or die(mysql_error());
    mysql_select_db("***") or die(mysql_error());
    $update = mysql_query("UPDATE completed SET followupsent = NOW() WHERE id = '$id'") or die(mysql_error());
    
    }
    ?>
    

     

    Works perfect, no errors when you go to the page that is being called in the cron job, but the cron job doesn't seem to be processing it. As I said before, i'm new to using Cron Jobs, could it be because i'm setting a header where the actual process takes place?

  2. Out of ideas regarding the cron jobs thing so any help appreciated. The closest I think i've got is:

     

    PHP: Error parsing /home/****/followup.php on line 4

     

    Which I guess was reading the file but not properly? Line 4 is:

     

    mysql_connect("localhost", "***", "***") or die(mysql_error());

  3. Right, got the php to run correctly and find the requested rows that are older than a week and only if the initial email has already been sent. Tested in browser it works properly and sends the email.

     

    Tried to put it in to cron jobs in cpanel using the following:

     

    php -q /home/***/followup.php

     

    where *** = full path

     

    but i'm getting an email coming through saying "No input file specified." Any ideas? It's the correct file name and i'm fairly sure the directory is correct as I was getting "Not a directory" before?

  4. Hi i'm having a go at this, but getting no output from the emails. Currently including the email file in to the file that processes the request that will be called in the CRON JOB, but I think there must be a better way of doing what i'm doing.

     

    Is there a way to say foreach row, send the email? Must be a better way of doing what i'm doing as it seems so long way round!

     

    See below for what i'm currently doing:

     

    <?
    // Connects to your Database
    mysql_connect("localhost", "****", "****") or die(mysql_error());
    mysql_select_db("****") or die(mysql_error());
    $data = mysql_query("SELECT * FROM completed WHERE followupsent='0000-00-00 00:00:00' AND valuesent = DATE_SUB(NOW(), INTERVAL 7 DAY)")
    or die(mysql_error());
    
    while($info = mysql_fetch_array( $data ))
    {
    include 'followupemail.php?id='.$data['id'].'';
    }
    ?>
    

     

    followupsent is by default 0000-00-00 00:00:00 so i'm checking to make sure the follow up has not been sent yet, and then checking valuesent to see if it's 7 days since the first email was sent.

  5. I send the NOW time and date to the database when the first email is sent. I've used Cron Jobs before but never set something up in a script that i've done myself.

     

    If I set up a cron job for it, would I just tell it to run the page that sends the email for each member that it needs to?

     

    Thanks for the advice, I thought it'd be cron jobs, but never used it on my own script!

  6. Hi, I currently have a page in an admin section, with members details, and 2 buttons. When you set a value in a field, then click the first button, it navigates to a php page which sends a HTML email to the member's email address with the value from the field and then directs back to the previous page. The second button when clicked, does the same, but with a different email. This is a follow up email, a reminder, to the first.

     

    My dilemma is, how would I get the follow up email to send automatically 7 days after the first email is sent? Is there a way?

     

    Many thanks in advance!

  7. Ah ok, so does it doesn't grab the results from the xml? As the page that calls the page that has the code above, then calls the results as follows:

     

    $xml = simplexml_load_string($str);
    
    $vrm = (string)$xml->DataArea->Vehicles->Vehicle->VRM_Curr; 
    $make = (string)$xml->DataArea->Vehicles->Vehicle->DVLA_Make;
    $model = (string)$xml->DataArea->Vehicles->Vehicle->DVLA_Model; 

     

    So would that mean the way that handles need changing?

  8. Here's what i've tried:

     

    $feeds = array('url1?','url2?');
    
    $fields = array(
                'strUserName'=>urlencode('username'),
                'strPassword'=>urlencode('password'),
                'strClientRef'=>urlencode('ref'),
                'strClientDescription'=>urlencode('desc'),
                'strKey1'=>urlencode('key'),
                'strVersion'=>urlencode('version'),
                'strVRM'=>urlencode($vrm)
            );
    
    foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
    rtrim($fields_string,'&');
    
    
    do {
    $ch = curl_init();
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,1); // 1 second timeout I'm impatient
    curl_setopt($ch,CURLOPT_URL,current($feeds));
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE);
    
    curl_setopt($ch,CURLOPT_POST,count($fields));
    curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
    
    $result = curl_exec($ch);
    } while( $result === FALSE && next($feeds) !== FALSE );
    
    curl_close($ch);
    
    $str = ob_get_contents();
    ob_end_clean();

     

    The errors etc are handled by the next page:

     

    But seemingly it's not grabbing any info with what i'm using.

  9. Currently using the following which is working fine:

     

    //set POST variables
    $url = 'primaryurl.com';
    $fields = array(
                'strUserName'=>urlencode('***'),
                'strPassword'=>urlencode('***'),
                'strClientRef'=>urlencode('***'),
                'strClientDescription'=>urlencode('***'),
                'strKey1'=>urlencode('***'),
                'strVersion'=>urlencode('***'),
                'strVRM'=>urlencode(***)
            );
    
    
    //url-ify the data for the POST
    foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
    rtrim($fields_string,'&');
    
    //open connection
    $ch = curl_init();
    
    //set the url, number of POST vars, POST data
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_POST,count($fields));
    curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
    
    //execute post
    $result = curl_exec($ch);

     

    How would I go about adding in a backup url incase the first is down? Can I add it to the $url tag? Or would I be best to add $backupurl and then using it in the following part:

     

    //set the url, number of POST vars, POST data
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_POST,count($fields));
    curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);

     

    Saying if $url gives a response then use it, if not then use $backupurl?

     

    Any help appreciated massively.

  10. I tried the implode function and it just failed on me before.

     

    Do I do it just before I send the data to the database? As I'm passing these details to the final page of a multipage form using a session. So at the moment I have:

     

    $_SESSION['damage'] =$_POST['damage'];

     

    So $_SESSION['damage'] is holding the array. Should I strip it out of there and then work with $damage again?

  11. Haha, now I just feel dumb.

     

    The difference using echo $damage[0]; and echo $damage; is massive!!

     

    My issue with that kind of still stands now though, in that when submitted to the database, it'll still submit as "Array". From my understanding (that may be wrong!) I think I need to extract everything from inside the array before I post it to the database? Or would I just set a foreach statement and say "foreach $damage[] send to this field"?

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