PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
JAM
DevNet Resident
Posts: 2101 Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:
Post
by JAM » Sat Jul 17, 2004 3:43 pm
As you allready read up on the mail() function (you have done it right?
) you noticed that it works like most functions that you likely allready used. All it does is send a mail to someone. So, by taking the example provided by
kettle_drum above, you should figure it out pretty easy.
During the end of the approval-script, you need to place the mail() in an appropiate place, preferably somewhere at the same place as the script itself consider the testimonial is approved.
Try it out, using your own mail-addy as example to see if it works, and let us know if you still get issues.
AVATAr
Forum Regular
Posts: 524 Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:
Post
by AVATAr » Sat Jul 17, 2004 5:59 pm
well inmediatelly after that use the mail funcion
kettle_drum said:
mail("
to@mail.com ", "The Subject bla bla bla", "The message bla bla bla")
//mail(to, subject, message);
Lucnet
Forum Commoner
Posts: 61 Joined: Sat Jun 26, 2004 5:28 pm
Location: Alabama
Contact:
Post
by Lucnet » Sat Jul 17, 2004 8:59 pm
I understand the mail function. i just don't really see how to get the scrept to look at it. Like when I click approve. I am thinking it should be something like:
Code: Select all
if approved='y' then mail("{$emai}l", "The Subject bla bla bla", "The message bla bla bla")
//mail(to, subject, message);
If so I am not sure how to do this. I am over looking something. I know its there but I am not seeing it. Sorry for the hassle.
AVATAr
Forum Regular
Posts: 524 Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:
Post
by AVATAr » Sat Jul 17, 2004 9:25 pm
Why dont you show us your code, and maybe we can help you.
Lucnet
Forum Commoner
Posts: 61 Joined: Sat Jun 26, 2004 5:28 pm
Location: Alabama
Contact:
Post
by Lucnet » Sat Jul 17, 2004 10:07 pm
Ok here it is:
Code: Select all
<?
$status = (!empty($_GET['status']) ? $_GET['status'] : '%');
include "../inc/config.php";
$displaymessage =0;
switch($action) {
case "approve":
$displaymessage =1;
db();
mysql_query("UPDATE ls_testimonials SET approved='y' WHERE id=$id");
db_close();
break;
case "hold":
$displaymessage =2;
db();
mysql_query("UPDATE ls_testimonials SET approved='h' WHERE id=$id");
db_close();
break;
case "delete":
$displaymessage =3;
db();
mysql_query("DELETE FROM ls_testimonials WHERE id=$id");
db_close();
break;
default:
break;
}
db();
$query = "SELECT * FROM ls_testimonials WHERE approved LIKE '$status'";
$formdata_res=mysql_query($query) or die("query failed: " . mysql_error());
$content.="<body bgcolor=#F1F1F1>
<table width=760 height=599 border=0 cellpadding=0 cellspacing=0>
<tr>
<td height=10 colspan=2> </td>
</tr>
<tr>
<td width=146 valign=top>
<table width=150 border=1 cellpadding=2 cellspacing=2 bordercolor=#F1F1F1>
<tr>
<td bordercolor=#000000 bgcolor=#CCCCCC><b>Menu</b></td>
</tr>
<tr>
<td bordercolor=#000000 bgcolor=#FFFFFF>
<p><a href=add.php>Add Testimonials</a><br>
<a href=manage.php?status=n>Check New</a><br>
<a href=manage.php?status=h>Check On Hold</a><br>
<a href=manage.php?status=y>Check Active</a><br>
<a href=code.php>Generate Code</a></p>
</td>
</tr>
<tr>
<td bordercolor=#F1F1F1> </td>
</tr>
<tr>
<td bordercolor=#000000 bgcolor=#CCCCCC><b>Records</b></td>
</tr>
<tr>
<td bordercolor=#000000 bgcolor=#FFFFFF>Active<br>
On Hold<br>
New</td>
</tr>";
if ($displaymessage == 0)
{
$content.="<tr><td></td></tr>";
}
else if ($displaymessage ==1)
{
$content.="<tr><td bordercolor=#000000 bgcolor=#FFFFFF>Item Approved</td></tr>";
}
else if ($displaymessage ==2)
{
$content.="<tr><td bordercolor=#000000 bgcolor=#FFFFFF>Item On Hold</td></tr>";
}
else if ($displaymessage ==3)
{
$content.="<tr><td bordercolor=#000000 bgcolor=#FFFFFF>Item Deleted</td></tr>";
}
$content.="</table>
</td>";
$content.="<td width=614 valign=top>
<table width=100% border=1 cellpadding=2 cellspacing=2 bordercolor=#F1F1F1>";
while ($formdata=mysql_fetch_object($formdata_res)) {
$client_id=htmlentities($formdata->client_id);
$link_display=htmlentities($formdata->link_display);
$email=htmlentities($formdata->email);
$company=htmlentities($formdata->company);
$testimonials=htmlentities($formdata->testimonials);
$content.="<tr>
<td width=31% bordercolor=#000000 bgcolor=#CCCCCC><b>Customer ID#:</b>{$client_id}</td>
<td width=36% bordercolor=#000000 bgcolor=#CCCCCC><center><a href='?id={$formdata->id}&action=approve'><img src=../inc/skins/default/images/approve.gif width=17 height=17 border=0 ALT=Approve></a>
<a href='?id={$formdata->id}&action=hold'><img src=../inc/skins/default/images/hold.gif width=17 height=17 border=0 ALT=Hold></a>
<a href='?id={$formdata->id}&action=delete'><img src=../inc/skins/default/images/delete.gif width=17 height=17 border=0 ALT=Delete></a> </center></td>
<td width=33% bordercolor=#F1F1F1> </td>
</tr>
<tr bordercolor=#000000 bgcolor=#FFFFFF>
<td>Displayed Link</td>
<td>Website</td>
<td>E-mail</td>
</tr>
<tr bordercolor=#000000 bgcolor=#FFFFFF>
<td>{$link_display}</td>
<td><a href='{$company}' target=new>{$company}</a></td>
<td><a href='mailto:{$email}'>{$email}</a></td>
</tr>
<tr>
<tr>
<td colspan=3 bordercolor=#000000 bgcolor=#FFFFFF>Testimonial : <textarea style=width=450; border: 1; rows=1>{$testimonials}</textarea></td>
</tr>
<tr bordercolor=#F1F1F1 bgcolor=#F1F1F1>
<td colspan=3> </td>
</tr>";
//if (&action=y) mail("{$email}", "Testimonial approved", "Your testimonial that was submitted ".$COMPANY_name." was approved. You can view it at <a href=".$URL_maindir.">".$COMPANY_name."</a> if you would like.");
//mail(to, subject, message);
}
db_close();
$content.="</table></td>
</tr>
<tr align=center valign=bottom>
<td height=40 colspan=2>
<table width=300 border=0 cellspacing=0 cellpadding=0>
<tr>";
//<!-- DO NOT REMOVE THIS COPYRIGHT CODE BELOW -->
$content.="<td><div align=center>Powered by: <a href='http://www.lssctips.com'>LS Testimonials</a><br>
Ver. 1.0</div></td>
</tr>
</table>
</td>
</tr>
</table>";
//<!-- DO NOT REMOVE THIS COPYRIGHT CODE ABOVE -->
include_once("../inc/html.php");
?>
zenabi
Forum Commoner
Posts: 84 Joined: Mon Sep 08, 2003 5:26 am
Location: UK
Post
by zenabi » Sun Jul 18, 2004 5:35 am
Put your mail function in your switch-case statement:
Code: Select all
switch($action) {
case "approve":
$displaymessage =1;
db();
mysql_query("UPDATE ls_testimonials SET approved='y' WHERE id=$id");
db_close();
/* PUT MAIL FUNCTION HERE */
break;
Lucnet
Forum Commoner
Posts: 61 Joined: Sat Jun 26, 2004 5:28 pm
Location: Alabama
Contact:
Post
by Lucnet » Sun Jul 18, 2004 8:45 pm
Ok that worked if I manually put a valid email in the mailto section. I would like it to email the person that I have approved. Seems like I should be able to just put $email in the mailto and it work. But it doesn't seems to. Any ideas.
Example of mailto with the $email in the mailto:
Code: Select all
<?
case "approve":
$displaymessage =1;
db();
mysql_query("UPDATE ls_testimonials SET approved='y' WHERE id=$id");
db_close();
mail("$email", "Testimonial approved", "Your testimonial that was submitted ".$COMPANY_name." was approved. You can view it at http:".$URL_maindir." if you would like.");
//mail(to, subject, message);
break;
?>