Jump to content

Hamish

Members
  • Posts

    46
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Hamish's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi frost110, Are you saying that my original code should work as is. Hamish.
  2. Hi taith, The dropdown populates with the result of the query in the form of an email address, ie fredblogs@pipex.net. You can select the an email address and it holds in the text box, allowing "from", "subject" and "message" to be filled in. Pressing submit gives the impression that the email has be forwarded and the form fields clear, no error message but the email does not arrive. I have tested the script without the dropdown and the emails arrive, the problem seems to be in getting from the dropdown to "input" Regards Hamish
  3. Hi taith, Thanks for the modified query which I have changed and tried, however when submitted the script does not get either success or failure from warnings nor is the email delivered. Regards Hamish
  4. Hi All, This is my second attempt at using a MySQL generated query to populate a dropdown box to send email. The query populates the dropdown box “ok”, allowing the desired email address to be selected. The problem seems to be in using this email address as the input. How do I get the selected email to then become an input? Any ideas much appreciated. Hamish <?php //Check whether the submission is made if(isset($hidSubmit)){ //Declarate the necessary variables $mail_to=$PLemailAddress; $mail_from=$txtEmailfrm2; $mail_sub=$txtSub2; $mail_mesg=$txtMsg; //Check for success/failure of delivery if(mail($mail_to,$mail_sub,$mail_mesg,"From:$mail_from Reply-to:$txtEmailfrm2")) echo "<span class='textred'>E-mail has been sent successfully from $mail_sub to $mail_to</span>"; else echo "<span class='textred'>Failed to send the E-mail from $mail_sub to $mail_to</span>"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" /> <title>php email</title> </head> <body> <form name="frmsendmail" method="post" action="" onSubmit="return ValidationForm()"> <table width="100%" border="0"> <tr> <td><div align="right">To</div></td> <td><select name="PLemailAddress"> <option>Please select a email from the list</option> <?php include ("opendbincludeA.php"); $query ="SELECT P_Leader.PLemailAddress FROM P_Leader"; $query = mysql_query($query); $query_row=mysql_num_rows($query); while ($row=mysql_fetch_array($query)) { echo "<option value=".$row['PLemailAddress'].">".$row['PLemailAddress']."</option>"; } ?> </select></td> </tr> <tr> <td width="34%"><div align="right">From</div></td> <td width="66%"><input name="txtEmailfrm2" type="text" id="txtEmailfrm2" /></td> </tr> <tr> <td><div align="right">Subject</div></td> <td><input type="txtSub2" name="textfield" /></td> </tr> <tr> <td><div align="right">Message</div></td> <td><textarea name="txtMsg" cols="50" rows="6"></textarea></td> </tr> <tr> <td><div align="right"></div></td> <td><input type="submit" name="Submit" value="Submit" /></td> </tr> </table> </form> </body> </html>
  5. This bit of code works fine <?php //Check whether the submission is made if(isset($hidSubmit)){ //Declarate the necessary variables $mail_to=$txtEmailto2; $mail_from=$txtEmailfrm2; $mail_sub=$txtSub2; $mail_mesg=$txtMsg; //Check for success/failure of delivery if(mail($mail_to,$mail_sub,$mail_mesg,"From:$mail_from Reply-to:$txtEmailfrm2")) echo "<span class='textred'>E-mail has been sent successfully from $mail_sub to $mail_to</span>"; else echo "<span class='textred'>Failed to send the E-mail from $mail_sub to $mail_to</span>"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" /> <title>Untitled Document</title> </head> <body> <p> </p> <form action="" method="post" name="frmsendmail" id="frmsendmail" onsubmit="return ValidationForm()"> <table width="100%" border="0"> <tr> <td width="33%" align="right" class="text">To : </td> <td width="67%"><input name="txtEmailto2" type="text" class="input" id="txtEmailto22" size="30" maxlength="100" /> </td> </tr> <tr> <td align="right" class="text">From : </td> <td><input name="txtEmailfrm2" type="text" class="input" id="txtEmailfrm22" size="30" maxlength="100" /> </td> </tr> <tr> <td align="right" class="text">Subject : </td> <td><input name="txtSub2" type="text" class="input" id="txtSub22" size="30" maxlength="100" /> </td> </tr> <tr> <td align="right" class="text">Message: </td> <td><textarea name="txtMsg" cols="50" rows="10" class="input" id="textarea"></textarea> </td> </tr> <tr> <td align="right"><input name="hidSubmit" type="hidden" id="hidSubmit" value="true" /> </td> <td><input name="Submit" type="submit" class="input" value="Send" /> <input name="Submit2" type="reset" class="input" value="Reset" /> </td> </tr> </table> </form> <p> </p> </body> </html> What I have been trying to do is replace the "txtEmailto2" ie the recipient with a drop down box populated by a query . The query code also works fine and populates the dropdownbox <form> <select name="txtEmailto2"> <option>Please select a email from the list</option> <? include ("opendbincludeA.php"); $query ="SELECT P_Leader.PLemailAddress FROM P_Leader"; $query = mysql_query($query); $query_row=mysql_num_rows($query); while ($row=mysql_fetch_array($query)) { echo "<option>".$row['PLemailAddress']."</option>"; } ?> </select> </form> When I try and join them together it doesn't work. Hamish
  6. I thought they were set in the "form table". I copied that bit of code from elsewhere and as I said before that section works on its own. Hamish
  7. Help ! There must be a simple answer to this but I can't see it
  8. Thanks sorted that bit, Now populating the dropdown and am able to select an address. The email appears to be sending but does not arrive at the destination. Hamish
  9. I am sorry if I appear stupid and I am just finding my way round php. I have added the option value as suggested, <form name="frmsendmail" method="post" action="" onSubmit="return ValidationForm()"> <table width="100%" border="0"> <tr> <td width="33%" align="right" class="text">To : <td width="67%"><select><option value="txtEmailto2"> <option>Please select a email from the list</option></select> <? include ("opendbincludeA.php"); $query ="SELECT P_Leader.PLemailAddress FROM P_Leader"; $query = mysql_query($query); $query_row=mysql_num_rows($query); while ($row=mysql_fetch_array($query)) { echo "<option value=".$row['PLemailAddress'].">".$row['PLemailAddress']."</option>"; } ?> </select> </tr> <tr> <td align="right" class="text">From : <td><input name="txtEmailfrm2" type="text" class="input" id="txtEmailfrm22" size="30" maxlength="100"> </tr> <tr> <td align="right" class="text">Subject : <td><input name="txtSub2" type="text" class="input" id="txtSub22" size="30" maxlength="100"> </tr> <tr> <td align="right" class="text">Message: <td><textarea name="txtMsg" cols="50" rows="10" class="input" id="textarea"></textarea> </tr> <tr> <td align="right"><input name="hidSubmit" type="hidden" id="hidSubmit" value="true"> <td><input name="Submit" type="submit" class="input" value="Send" /> <input name="Submit2" type="reset" class="input" value="Reset" /> </tr> </table> </form> but the returned query is still diplaying outside the dropdown box. Hamish
  10. Thanks dweir for that, I have tried what you suggested but must not have it right, the dynamic list is displaying outside the box as a list of email addresses, and as such can't be selected. <?php //Check whether the submission is made if(isset($hidSubmit)){ //Declarate the necessary variables $mail_to=$txtEmailto2; $mail_from=$txtEmailfrm2; $mail_sub=$txtSub2; $mail_mesg=$txtMsg; //Check for success/failure of delivery if(mail($mail_to,$mail_sub,$mail_mesg,"From:$mail_from Reply-to:$txtEmailfrm2")) echo "<span class='textred'>E-mail has been sent successfully from $mail_sub to $mail_to</span>"; else echo "<span class='textred'>Failed to send the E-mail from $mail_sub to $mail_to</span>"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" /> <title>Untitled Document</title> </head> <body> <form name="frmsendmail" method="post" action="" onSubmit="return ValidationForm()"> <table width="100%" border="0"> <tr> <td width="33%" align="right" class="text">To : <td width="67%"><select><option value="txtEmailto2"> <option>Please select a email from the list</option></select> <? include ("opendbincludeA.php"); $query ="SELECT P_Leader.PLemailAddress FROM P_Leader"; $query = mysql_query($query); $query_row=mysql_num_rows($query); while ($row=mysql_fetch_array($query)) { echo "<option>".$row['PLemailAddress']."</option>"; } ?> </select> </tr> <tr> <td align="right" class="text">From : <td><input name="txtEmailfrm2" type="text" class="input" id="txtEmailfrm22" size="30" maxlength="100"> </tr> <tr> <td align="right" class="text">Subject : <td><input name="txtSub2" type="text" class="input" id="txtSub22" size="30" maxlength="100"> </tr> <tr> <td align="right" class="text">Message: <td><textarea name="txtMsg" cols="50" rows="10" class="input" id="textarea"></textarea> </tr> <tr> <td align="right"><input name="hidSubmit" type="hidden" id="hidSubmit" value="true"> <td><input name="Submit" type="submit" class="input" value="Send" /> <input name="Submit2" type="reset" class="input" value="Reset" /> </tr> </table> </form> </body> </html>
  11. Thanks DanielO for the very quick response I'm sorry I don't understand I'm very new to php. Could you show me an example? Hamish
  12. Hi All, This is my first attempt at using a dropdown box to submit data. I am trying to use a dropdown box to pass an email address to an email form and then send to the recipient. So far I have: This returns the email addresses to a dropdown box . <body> <select name="txtEmailto2"> <option>Please select a email from the list</option> <? include ("opendbincludeA.php"); $query ="SELECT P_Leader.PLemailAddress FROM P_Leader"; $query = mysql_query($query); $query_row=mysql_num_rows($query); while ($row=mysql_fetch_array($query)) { echo "<option>".$row['PLemailAddress']."</option>"; } ?> </select> </form> </body> The following is a simple email form, which sends an email to the recipient typed in text box. I have tried to use the dropdown box code above to replace the typed input text box without success. I can find no example as to what the syntax should for using the "option". I am hoping someone with more experience with dropdown boxes / php will be able to help. Regards Hamish <?php //Check whether the submission is made if(isset($hidSubmit)){ //Declarate the necessary variables $mail_to=$txtEmailto2; $mail_from=$txtEmailfrm2; $mail_sub=$txtSub2; $mail_mesg=$txtMsg; //Check for success/failure of delivery if(mail($mail_to,$mail_sub,$mail_mesg,"From:$mail_from Reply-to:$txtEmailfrm2")) echo "<span class='textred'>E-mail has been sent successfully from $mail_sub to $mail_to</span>"; else echo "<span class='textred'>Failed to send the E-mail from $mail_sub to $mail_to</span>"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" /> <title>Untitled Document</title> </head> <body> <form name="frmsendmail" method="post" action="" onSubmit="return ValidationForm()"> <table width="100%" border="0"> <tr> <td width="33%" align="right" class="text">To : <td width="67%"><input name="txtEmailto2" type="text" class="input" id="txtEmailto22" size="30" maxlength="100"> </tr> <tr> <td align="right" class="text">From : <td><input name="txtEmailfrm2" type="text" class="input" id="txtEmailfrm22" size="30" maxlength="100"> </tr> <tr> <td align="right" class="text">Subject : <td><input name="txtSub2" type="text" class="input" id="txtSub22" size="30" maxlength="100"> </tr> <tr> <td align="right" class="text">Message: <td><textarea name="txtMsg" cols="50" rows="10" class="input" id="textarea"></textarea> </tr> <tr> <td align="right"><input name="hidSubmit" type="hidden" id="hidSubmit" value="true"> <td><input name="Submit" type="submit" class="input" value="Send" /> <input name="Submit2" type="reset" class="input" value="Reset" /> </tr> </table> </form> </body> </html>
  13. There must be a simple answer to it I, I thought it may have been a copy and paste problem so tried again, but it makes no difference, am still getting "failed to send message from" somebody must have hit this snag before. I would be grateful for any help. Regards Hamish
  14. That's where I got the code, but there must be something not quite right. But I can't see it! Hamish
  15. Hi All, I have the following email script which I can't get to work, please can anyone see where I am going wrong. Regards Hamish <?php //Check whether the submission is made if(isset($hidSubmit)){ //Declarate the necessary variables $mail_to=$txtEmailto; $mail_from=$txtEmailfrm; $mail_sub=$txtSub; $mail_mesg=$txtMsg; //Check for success/failure of delivery if(mail($mail_to,$mail_sub,$mail_mesg,"From:$mail_from/r/nReply-to:$mail_from")) echo "<span class='textred'>E-mail has been sent successfully from $mail_sub to $mail_to</span>"; else echo "<span class='textred'>Failed to send the E-mail from $mail_sub to $mail_to</span>"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" /> <title>Untitled Document</title> </head> <body> <form name="frmsendmail" method="post" action="" onSubmit="return ValidationForm()"> <table width="100%" border="0"> <tr> <td width="33%" align="right" class="text">To : <td width="67%"><input name="txtEmailto2" type="text" class="input" id="txtEmailto22" size="30" maxlength="100"> </tr> <tr> <td align="right" class="text">From : <td><input name="txtEmailfrm2" type="text" class="input" id="txtEmailfrm22" size="30" maxlength="100"> </tr> <tr> <td align="right" class="text">Subject : <td><input name="txtSub2" type="text" class="input" id="txtSub22" size="30" maxlength="100"> </tr> <tr> <td align="right" class="text">Mesage(body) : <td><textarea name="txtMsg" cols="50" rows="10" class="input" id="textarea"></textarea> </tr> <tr> <td align="right"><input name="hidSubmit" type="hidden" id="hidSubmit" value="true"> <input name="Submit" type="submit" class="input" value="Send"> <td><input name="Submit2" type="reset" class="input" value="Reset"> </tr> </table> </form> </body> </html>
×
×
  • 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.