how to send mail with my form data

the mail() function

Moderators: macek, egami, gesf

Naru
New php-forum User
New php-forum User
Posts: 1
Joined: Mon Jun 25, 2012 7:55 pm

how to send mail with my form data

Postby Naru » Mon Jun 25, 2012 8:12 pm

my code is here. mail not showing complete data .please correct my code...

<?php
mysql_connect("localhost","root","");
mysql_select_db("Users");
$mysql_query =("SELECT uid,`Name`,Department,Problem,Ext_no,Ip_Add,Remark,Email FROM entryform ORDER BY entryform.uid DESC limit 1 ");
$result = mysql_query($mysql_query);
while($data = mysql_fetch_row($result)){
echo(" <td >
<tr>
<td> Complaint NO. :- $data[0]</br></br></td>
<td> NAME :- $data[1]</br></br>
</td>
<td> DEPARTMENT :- $data[2] </br></br>
</td>
<td> PROBLEM :-$data[3] </br></br> </td>
<td> EXT. NO.. : $data[4]</br></br> </td>
<td> IP ADDRESS :- $data[5] </br></br> </br>
<td> REMARK :- $data[6] </br></br> </br>
<td> Mail ID :- $data[7] </br></br> </br>
</td>
</tr>
");
}
$to = "support.kaizen@rpr.jspl.com";
$subject = "user complaint!";
$massage = "$result";
if (mail($to, $subject, $massage)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
?>

paragbhavsar
New php-forum User
New php-forum User
Posts: 8
Joined: Thu Jun 28, 2012 4:02 am
Location: Pune
Contact:

Re: how to send mail with my form data

Postby paragbhavsar » Thu Jun 28, 2012 5:07 am

Following is modified code

<?php
mysql_connect("localhost","root","");
mysql_select_db("Users");
$mysql_query =("SELECT uid,`Name`,Department,Problem,Ext_no,Ip_Add,Remark,Email FROM entryform ORDER BY entryform.uid DESC limit 1 ");
$result = mysql_query($mysql_query);
$message = '';
while($data = mysql_fetch_row($result)){
$message .= " <td >
<tr>
<td> Complaint NO. :- $data[0]</br></br></td>
<td> NAME :- $data[1]</br></br>
</td>
<td> DEPARTMENT :- $data[2] </br></br>
</td>
<td> PROBLEM :-$data[3] </br></br> </td>
<td> EXT. NO.. : $data[4]</br></br> </td>
<td> IP ADDRESS :- $data[5] </br></br> </br>
<td> REMARK :- $data[6] </br></br> </br>
<td> Mail ID :- $data[7] </br></br> </br>
</td>
</tr>
";
}
$to = "support.kaizen@rpr.jspl.com";
$subject = "user complaint!";
if (mail($to, $subject, $message)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
?>

You will have to store all data in a string and pass the string to mail function as done above.

- Parag Bhavsar

Email - parag.bhavsar@gmail.com
Skype - paragbhavsar7777

http://in.linkedin.com/pub/parag-bhavsar/4/554/5a3
https://twitter.com/ParagBhavsar
http://digg.com/paragbhavsar
https://plus.google.com/112583269132107620439/posts

Cell No - 9730077617


Return to “PHP coding => Mail”

Who is online

Users browsing this forum: No registered users and 1 guest