Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

Help required regarding mail confirmation

the mail() function

Moderators: macek, egami, gesf

Help required regarding mail confirmation

Postby myfahim » Thu Apr 26, 2012 11:59 pm

Hi,

I want to receive mail when a user submit a form. I did it by:

Code: Select all
$sendto = "email@myemail.com";
$subject = "New post !!!";
$message = "A new post Received";
$header = "From: NEW_POST <no-reply@myemail.com>\r\n";
mail($sendto, $subject, $message, $header);


Its working. But I want to receive mail as "A new post Received from JOHN" where the name "JOHN" is collected from the form that he entered as his name.
Please help me :help:

Fahim
myfahim
New php-forum User
New php-forum User
 
Posts: 8
Joined: Thu Apr 26, 2012 11:13 pm

Re: Help required regarding mail confirmation

Postby minimihi » Fri Apr 27, 2012 2:02 am

Get that data from form and insert it into string :?

Seems like you trying to do something more advanced even without knowing basic of basics :?
User avatar
minimihi
New php-forum User
New php-forum User
 
Posts: 238
Joined: Sat Apr 14, 2012 11:57 am
Location: Vilnius, Lithuania

Re: Help required regarding mail confirmation

Postby egami » Fri Apr 27, 2012 4:27 am

$name = trim(strip_tags($_POST['name']));
$subject = "A new post as arrived from $name";
User avatar
egami
php-forum GURU
php-forum GURU
 
Posts: 2197
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Re: Help required regarding mail confirmation

Postby myfahim » Sat Apr 28, 2012 12:08 am

Thanks egami....it is working :) :D :D :D

I am a network engineer. I don't know PHP-MySQL. I just did it without anything.

Thank again.
myfahim
New php-forum User
New php-forum User
 
Posts: 8
Joined: Thu Apr 26, 2012 11:13 pm

Re: Help required regarding mail confirmation

Postby myfahim » Sat Apr 28, 2012 11:30 pm

Hi egami, I did it as u, and its working. Now I need something more like:

There is a table in my database which has a field of auto generate serial number. What should I do if I want to send this serial number by mail?

In your previous help:
Code: Select all
    $name = trim(strip_tags($_POST['acc_name']));
    $message = "A new post received from $name .";


I can't use $_POST['serial_no'] as it is not an input type. The serial number is auto generated.

Please help :(

Fahim
myfahim
New php-forum User
New php-forum User
 
Posts: 8
Joined: Thu Apr 26, 2012 11:13 pm

Re: Help required regarding mail confirmation

Postby egami » Mon Apr 30, 2012 4:32 am

I'm also a neteng by trade.. I just do PHP on the side..

Make a call to the db, and pull the data you need..


$query = "SELECT serial_no FROM table WHERE column = '$value'";
$result = mysql_query($query) or die ("ERROR.. : ".mysql_error());
if (mysql_num_rows($result) > 0) {
$row = mysql_fetch_assoc($result);
$serial_no = $row['serial_no'];
} else {
echo "Something went wrong with the query that did not produce an SQL error. Check your query.";
}


so, replace table with your table name.
replace column with the name of the column, this should be like, username or user_id or something that is associated with the particular user
and then add the value in there.

Should be all you need.. then you just plug in the serial number to the variable we created before..
User avatar
egami
php-forum GURU
php-forum GURU
 
Posts: 2197
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Re: Help required regarding mail confirmation

Postby myfahim » Tue May 01, 2012 6:49 am

hey...egami, thanks.
it is working.
i'll knock u if i fail to do something....
plz don't mind. and plz tell me ur email address if u don't have any problem.
take care.
myfahim
New php-forum User
New php-forum User
 
Posts: 8
Joined: Thu Apr 26, 2012 11:13 pm


Return to PHP coding => Mail

Who is online

Users browsing this forum: Google [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.