Click to See Complete Forum and Search --> : sending a mail using <a href>
keko2005
08-29-2005, 02:37 PM
i have a list of images from my db, i wanna put a relay link next to each one as they print out from the db(this i know how to do), what i dont know hwo to do is when the user clicks the links, what should i do to make it send the image with a mail function(which i have written already in a seperate class n works), and reload the page to leave a message if it worked or not?
studbuckman
08-29-2005, 04:11 PM
Have you tried embedding the mail() function directly in the link? Something like...
<A HREF="somepage.html" onClick="<?php mail('address', 'subject', 'message'); ?>">
keko2005
08-29-2005, 06:28 PM
well this is the script i wrote, what happens is, when the page loads, it automatically send me 4 email, 4 because thats the rows i have in the db, so if i had 10, i would have 10 new emails, when i click the link, i recieve an addition 4 mails? whats going on with this?
$result = mysql_query($query);
while($row = mysql_fetch_array($result)){
extract($row);
$string[] = '<tr><td><a href="http://'.$path.$row['filename'].'">'.$row['filename'].
'</a></td><td>'.$row['Artist'].'</td><td>'.$row['Length'].'</td><td>'.$row['Size'].
'</td><td>'.$row['Date'].'</td><td><a href="#" onClick="'.mailme().'">relay</a></td></tr>'."\n";
}
function mailme(){
mail("keko2004@nyc.rr.com","test","test");
}
bokeh
08-29-2005, 06:41 PM
Just to make it a bit clearer this is the equivalent of your code. As you can see you have a mail command in the while loop so every time the loop rolls you get a mail.$result = mysql_query($query);
while($row = mysql_fetch_array($result)){
extract($row);
$string[] = '...'."\n";
mail("keko2004@nyc.rr.com","test","test");
}And this: <a href="#" onClick="'.mailme().'"> is a confusion. Someonre is trying to mix javascript and PHP.
keko2005
08-29-2005, 07:00 PM
i wasnt trying to mix JScript with it, i dont know jscript, so how do i go about this, so that it doesnt automatically send the mail, the user has to do something?
bokeh
08-29-2005, 07:38 PM
Like this: <a href="mailer_script.php?key=unique_info_here">Now have your mailer script send it to you.
keko2005
08-29-2005, 07:45 PM
how is this working
<a href="mailer_script.php?key=unique_info_here">
mailer script is the pahge witrh my mail function correct?, but im not sure what to make of the ?key=unique-info-here">
bokeh
08-29-2005, 07:52 PM
im not sure what to make of the ?key=unique-info-here">Well there must be some method in your madness. If they click on a clink and you receive an email I'm sure you want to know which link they clicked on. If you want to be emailed when they click any link but not be told which link they clicked just omit the query string.
keko2005
08-29-2005, 07:55 PM
i knew we were on the wrong page, and of course i have somthing behind my madness. i print lets say audio file paths from a db. i want the user to be able to click a link next to the path that was printed, and it will email them the media file, i dont want to knw if they clicked it. sorry for not making it more clear
keko2005
08-29-2005, 08:18 PM
got it
thanks, i might have 1 more question, but not at this moment, thanks man