Jump to content

Recommended Posts

I want to do something like this,

 

I had a html query submission form linked to php.

 

I want to send the output generated after php execution to the user through mail id provided in the form, in a manner such that when user click submit button, he well be redirected to thank you page and php keeps on running in the background and as soon as the output is generated, it will be send to the end user through email. As my query takes time to execute, so I don't want the end user to keep waiting till the program gets finish.

 

 

Here is my code:

 

<?php
$seq = $_POST['seq'];
    if (isset($_POST['seq']))
    {
$b = fopen("sequence.txt", "w");
fwrite($b, $seq);
fclose($b);
system("perl /opt/lampp/htdocs/matepred/blast/bin/scriptforblastcompleterun.pl sequence.txt nr > out");
system("perl /opt/lampp/htdocs/matepred/blast/bin/format.pl > output");
system("perl /opt/lampp/htdocs/matepred/blast/bin/testing.pl output");
  echo "<div align='center'><font color='blue'><b>RESULT</font></div>";
$i=1;
$files = array();
foreach (glob("file_*.out")as $file)
{
 $files[] = $file;
$b = fopen("/opt/lampp/htdocs/matepred/blast/bin/$file", "r");
$s=fgets($b);
fclose($b);
echo "<table border=10. align=center><tr bgcolor=lightgreen><th>SerialNo</th><th>Value</th><th>Decision</th><th></tr>";
echo '<td>'. $i++
. '</td>';
   
echo "<td>$s</td>";
if($s>=0)
{
echo "<td>Yes</td>";
}
else
{

echo"<td>No</td>";
}
echo "</table>";

}
}

?>

 

html table part marked in red here is the output which I want to send back to the user.

 

Can anybody help me in linking my php output to the mail.

Thanks in advance.

 

 

It would be interesting to know a good solution to this. My first thoughts would be to have different threads handling this, one handling your presentation logic and another handling the e-mail side of things - I may be incorrect here, so will be best to wait for some of the more experienced developers to have their input.

I had saved the results in a text file and now  trying to send these to the user via provided mail using localhost on ubuntu system.

 

Code :

 

$to=$_POST['email'];
$subject='Your  results';
$body=$data;    (//here $data stores the output file in text format)
$from="http://localhost/matepred/blast/bin/new.php";
mail( $from, $to, $subject, $body);

 

 

But it isn't sending any mail. Can anyone help me to know the problem with the code. Or is this a  problem with localhost?

Do you have a working SMTP server running on your localhost also? The mail function won't simply send an e-mail for you unless you have SMTP set up too. There are some good free examples such as smtp4dev or fakesmtp that should help you get on your way. 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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