here is a part of my cron code
<?php
echo "<h2>debut</h2>";
$conbase = new mysqli("xxx.xxx.xxx.xxx", "-------", "xxxxxxxxxx", "xxxxxxxxx");
if ($conbase->connect_errno) {
echo "Echec lors de la connexion a MySQL : (" . $conbase->connect_errno . ") " . $conbase->connect_error;
}
else{
echo "<p>con OK 1234-3</p>";
$req="SELECT refsub FROM atraiter WHERE traite=0";
$resultat = $conbase->query($req);
if(!$resultat){
echo "<p>Echec lors de la requete : <br>".$req." (" . $conbase->errno . ") " . $conbase->error;
}
else
{
echo "<p>req OK</p>";
$resultat->data_seek(0);
while ($afaire=$resultat->fetch_assoc()) {
$idsub=$afaire['refsub'];
echo "<p>traitement de ".$idsub."</p>";
//fmail IS YOUR CLIENT EMAIL
$nomParams=array("fmail","_STATUS","_TRANSACTION_ID");
$params=array("fmail" => "","_STATUS"=> "","_TRANSACTION_ID"=> "");
$nbParam=count($params);
$erreur=0;
for($item=0;$item<$nbParam;$item++)
{
echo "<p>RECHERCHE de ".$nomParams[$item];
$reqParam="SELECT FieldValue FROM rsform_submission_values WHERE FieldName='".$nomParams[$item]."' AND SubmissionId=".$idsub;
if (!($resu = $conbase->query($reqParam))) {
$erreur++;
echo $nomParams[$item]." ---> est vide</p>";
}
else{
if ($leparam=$resu->fetch_assoc()) {
$params[$nomParams[$item]]=$leparam['FieldValue'];
echo " ---> trouve ".$params[$nomParams[$item]]."</p>";
}
else{
$erreur++;
echo " ---> est absent</p>";
}
}
}
$poursuivre=false;
if($erreur==0)
{
$poursuivre= ($params["_STATUS"]=1) && ($params["_TRANSACTION_ID"]!='');
}
else
{
echo "<p> erreur sur les donnees</p>";
}
if($poursuivre)
{
echo "<p>traitement de ".$idsub." idtrans=".$params['_TRANSACTION_ID']." mail=".$params['fmail']."</p>";
//BUILD YOUR MAIL HERE AND SEND IT
}
else{
echo "<p> TRANSACTION INVALIDE</p>";
}
}//while
}
echo "<p>fermeture</p>";
$conbase->close();
}
echo "<h2>fin</h2>";
?>
my special table name is atraiter and inside there is the submission number of the form.
to have the submission number I have this script in my
Script called after form has been processed section
$paypal = RSFormProPayPal::getInstance();
// Redirection vers l'accueil si pas d'achat
$paypal->args['cancel_return'] = 'https://www.mywebsite';
// Redirection vers le dialogue PPok si achat validé
$paypal->args['return'] = 'https://www.mywebsite/index.php?option=com_rsform&formId=00d&hash='.$_POST['form']['hash'];
if the payement is ok I redirect to a form (id=00) in wich I have put this in the
Script called on form display section to store the submission id in my special table
// Get the hash from the URL
if ($hash = JFactory::getApplication()->input->getCmd('hash'))
{
$db = JFactory::getDbo();
$db->setQuery("SELECT SubmissionId FROM #__rsform_submission_values WHERE FieldValue = " . $db->q($hash) . " AND FieldName='hash'");
$submissionId = $db->loadResult();
if ($submissionId)
{
// Use the RSForm! Pro helper to retrieve the replacements.
list($replace, $with) = RSFormProHelper::getReplacements($submissionId);
// Replace the placeholders.
$formLayout = str_replace($replace, $with, $formLayout);
//insertion du formulaire à traiter
$query = $db->getQuery(true);
$columns = array('refsub', 'traite');
$values = array($submissionId,0);
// Prepare the insert query.
$query
->insert($db->quoteName('#__atraiter'))
->columns($db->quoteName($columns))
->values(implode(',', $values));
// Set the query using our newly populated query object and execute it.
$db->setQuery($query);
$db->execute();
}
}
Of course you will have to adapt all this to your problem but the basic is here.
echo instruction are here only for debugging purpose.