...

View Full Version : Mail from Database



webandwe
06-27-2007, 05:12 PM
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
--------


<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>



Mymail.php



<?
$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....

Mwnciau
06-27-2007, 05:16 PM
What are you trying to do?


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

Where is $i being set?

webandwe
06-27-2007, 05:29 PM
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.



$MailToAddress = "$mail"; // your email address

rafiki
06-27-2007, 07:43 PM
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'];
}

webandwe
06-28-2007, 09:23 AM
thanks... :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum