Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Apr 2007
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Mail from Database

    Hi,

    Can someone please help here,

    I have a form where you have to enter a name that has been insterted into the DB.

    The script I use is called mymail.php, You make a contact form and it correct everything and send it out.

    I just want to make it so when you enter a name it takes the e-mail address from mysql and put it in at the e-mail section.


    My details
    ----------
    mysql = db = gomail table = users rows are "first" and "mail"


    Here is my mail script I just need to get the mail in the correct area on you typed in a mail.

    -------------------------------------------------------


    Form
    --------
    [html]
    <form action="mymail.php" method="post">
    <br />
    <table width="391" border="0" cellpadding="2" cellspacing="2">
    <tr>
    <td width="84" height="37">name</td>
    <td width="291"><input name="name" type="text" id="name" /></td>
    </tr>
    <tr>
    <td height="35"><span class="style4">email</span></td>
    <td><input name="email" type="text" id="email" /></td>
    </tr>
    <tr>
    <td height="47"><span class="style4">Description:</span></td>
    <td><p class="style4">
    <textarea name="comments" id="comments"></textarea>
    </p>
    <p class="style4">
    <input name="first" type="text" id="first" />
    </p></td>
    </tr>
    <tr>
    <td><span class="style4"></span></td>
    <td><input name="submit" type="submit" /></td>
    </tr>
    </table>
    <p>&nbsp;</p>
    <label></label>
    <br>
    <br>
    </form>
    [/html]


    Mymail.php

    PHP Code:
    <?
    $first 
    $_POST['first'];

    $con mysql_connect("localhost","**USERNAME***","****mypass***");
    if (!
    $con)
      {
      die(
    'Could not connect: ' mysql_error());
      }

    @
    mysql_select_db("gptesting_co_za_-_gomail") or die( "Unable to select database");
    $query="SELECT * FROM users WHERE first='$first'";
    $result=mysql_query($query);
    $num=mysql_numrows($result); 
    mysql_close();


    $first=mysql_result($result,$i,"first");
    $mail=mysql_result($result,$i,"mail");

    ?>

    <?php 
    # You can use this script to submit your forms or to receive orders by email.
    $MailToAddress "$mail"// your email address
    $redirectURL "http://www.test.co.za"// the URL of the thank you page.
    $MailSubject "Form"// the subject of the email
    $sendHTML FALSE//set to "false" to receive Plain TEXT e-mail
    $serverCheck TRUE// if, for some reason you can't send e-mails, set this to "false"

    //////I did not copied the rest of the script has it has no use....
    Last edited by webandwe; 06-27-2007 at 05:16 PM.

  • #2
    Regular Coder
    Join Date
    May 2006
    Location
    Wales
    Posts
    820
    Thanks
    1
    Thanked 82 Times in 79 Posts
    What are you trying to do?

    PHP Code:
    $first=mysql_result($result,$i,"first");
    $mail=mysql_result($result,$i,"mail"); 
    Where is $i being set?

  • #3
    New Coder
    Join Date
    Apr 2007
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am trying to make the script see that if it gets a first name it must supply the e-mail address and add it into mail.

    PHP Code:
    $MailToAddress "$mail"// your email address 

  • #4
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    i believe you want a mail merge?
    SELECT first, mail FROM mail_table
    then
    while ($row = mysql_fetch_array($query)) {
    //send mail to $row['mail'];
    //body Hello $row['first'];
    }

  • #5
    New Coder
    Join Date
    Apr 2007
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •