More than just mail

the mail() function

Moderators: egami, macek, gesf

Post Reply
User avatar
Posts: 312
Joined: Sat Apr 05, 2003 4:33 am
Location: Mansfield, UK

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: ... code=$code
You must do this to be able to use your account on the network.
If you feel you have recieved this e-mail in error, please e-mail");
$subject = "Welcome to NVAS!";
mail($email, $subject, $message, "From: <>");
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!!

Andrew Berry

User avatar
php-forum Super User
php-forum Super User
Posts: 1279
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India

Thu Feb 05, 2004 3:29 am

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,
you can put whatever value you want for $message.

New php-forum User
New php-forum User
Posts: 74
Joined: Sun Nov 24, 2002 6:48 pm
Location: katrineholm

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


mail($email, $subject, $message, "From: <>");

I hope this helps, and I hope the code don't suck ;)

Post Reply