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

More than just mail

the mail() function

Moderators: macek, egami, gesf

Postby bezmond » Sat Apr 05, 2003 5:15 am

to use an example script of mine: (which does include a lot of verification, hehe)

<?
include ("../../connections/connection.php");
$query = "select * from nvas_members";
$VID = mysql_query($query);
$VID = mysql_num_rows($VID);
$VID = $VID + 200000;
$query3 = "select * from nvas_members where email='$email'";
$addy = mysql_query($query3);
$rows = mysql_num_rows($addy);
$code = rand("10000000","99999999");
if ($rows == 0)
{
$password = rand("111111","888888");
$query2 = "insert into nvas_members (VID, password, firstname, lastname, email, country, division, code) VALUES ('$VID','$password','$firstname','$lastname','$email','$country','$division','$code')";
$result = mysql_query($query2) or die(mysql_error());
echo "A confirmation e-mail is being sent to the mail account you selected. Follow the instructions in this e-mail to complete your registration with NVAS.";

$message = ("
You, or someone using your e-mail account, has just registered with NVAS. To complete this registration, you need to visit the following URL:
http://irishair.org.uk/nvas/members/per ... code=$code
You must do this to be able to use your account on the network.
Thanks,
NVAS HQ
--
If you feel you have recieved this e-mail in error, please e-mail hq@nvas.net");
$subject = "Welcome to NVAS!";
mail($email, $subject, $message, "From: noreply@nvas.net <noreply@nvas.net>");
}
else
{
echo "Sorry, someone has already registered with this e-mail account. Please contact us if you feel there is an error!";
echo "<br>";
echo "If you feel you may already have a membership, please use our request password form for the account which is registered with this address.";
echo "<br>";
echo "You can view this account here";
}
?>

Hope this helps!!

Regards,
Andrew Berry
User avatar
bezmond
Moderator
Moderator
 
Posts: 312
Joined: Sat Apr 05, 2003 4:33 am
Location: Mansfield, UK

Postby nmathews » Tue Feb 03, 2004 1:56 pm

Alright.. the email script worked great for me, but i don't know if that even anwsered either of our questions. How do the results get emailed out. The way Bezmond set up his example returns a preset message.

Any help would be great!
nmathews
New php-forum User
New php-forum User
 
Posts: 2
Joined: Tue Feb 03, 2004 1:50 pm

Mail

Postby ruturajv » Thu Feb 05, 2004 3:29 am

Hi,
I still don't understand what message you want to mail,
refer to bezmond's code, $message is what you have in the message body,
So...
you can put whatever value you want for $message.
User avatar
ruturajv
php-forum Super User
php-forum Super User
 
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India

Postby nmathews » Thu Feb 05, 2004 10:15 am

It does work, but I want it to send the results of data in the body of the page. If you type:

$message = ("<input name="Posted By:" type="hidden" value="<?php echo $row_login['Firstname']; ?> <?php echo $row_login['Lastname']; ?>">");

and try to publish that, you get the $message as text on the page instead of being run. I'm sure there is suppose to be something in front of $message but what?
nmathews
New php-forum User
New php-forum User
 
Posts: 2
Joined: Tue Feb 03, 2004 1:50 pm

Postby tranquillo » Wed Apr 07, 2004 5:36 am

I'm quite a biginner at php to, but I'm guessing that this is what you wanna do...

put the form in a html page with action="next.php"

then put something like this in the next.php page:


Code: Select all

//get the form data into variables

$PersonNr = $_POST["PersonNr"];
$Fnamn = $_POST["Fnamn"];
$Email = $_POST["Email"];


//insert the data in the database

$medlemsQuery = "INSERT INTO Medlem VALUES ($PersonNr,'$Fnamn','$Email')";

$medlemsResultat = mysql_query($medlemsQuery);


//select the data from the database, you might want to ad some code that checks that it's inserted corectly as well...

$selectQuery = mysql_query("SELECT * FROM Medlem WHERE PersonNr=$PersonNr",$db);

$myrow = mysql_fetch_array($selectQuery)

//make the email you wanna send... with the data from the database/form...

$email = $myrow["Email"];
$subject = "whatever";
$message = "Hi" .$myrow["Fnamn"]. ".
asdflaksjdflkjasdf: " .$myrow["PersonNr"]. "
               
asldfkjasdlfkjdkk kdkdkddk



/
me";

mail($email, $subject, $message, "From: info@webbgalleriet.net <info@webbgalleriet.net>");


I hope this helps, and I hope the code don't suck ;)
tranquillo
New php-forum User
New php-forum User
 
Posts: 74
Joined: Sun Nov 24, 2002 6:48 pm
Location: katrineholm


Return to PHP coding => Mail

Who is online

Users browsing this forum: No registered users and 3 guests

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

cron