tags:

views:

46

answers:

2

Below is the code

<?php

ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);

include('config.php');

// table name
$tbl_name="temp_members_db";

// Random confirmation code
$confirm_code=md5(uniqid(rand()));

// values sent from form
$name=$_POST['name'];
$email=$_POST['email'];
$country=$_POST['country'];

// Insert data into database
$sql="INSERT INTO $tbl_name(confirm_code, name, email, password, country)VALUES('$confirm_code', '$name', '$email', '$password', '$country')";
$result=mysql_query($sql);

// if suceesfully inserted data into database, send confirmation link to email
if($result){

// ---------------- SEND MAIL FORM ----------------

// send e-mail to ...
$to=$email;

// Your subject
$subject="Your confirmation link here";

// From
$header="from: your name <your email>";

// Your message
$message="Your Comfirmation link \r\n";
$message.="Click on this link to activate your account \r\n";
//$message.="http://www.yourweb.com/confirmation.php?passkey=$confirm_code";
$message.="http://localhost/confirmation.php?passkey=$confirm_code";

// send email   
$sentmail = mail($to,$subject,$message,$header);

}

// if not found
else {
echo "Not found your email in our database";
}

// if your email succesfully sent
if($sentmail){
echo "Your Confirmation link Has Been Sent To Your Email Address.";
}
else {
echo "Cannot send Confirmation link to your e-mail address";
}

?>
A: 

whats the error you are getting and i think you try to send a email , if a mail server is not configured in local host you cant send emails

you can use a SMTP class to send mails using your SMTP mails like gmail

Sudantha
How to configured smtp
Aos
could you please help me with the command to install smtp server on ubuntu
Aos
You can use 'PHPMailer' Class http://www.phpclasses.org/browse/file/920.html , and send emails using a SMTP account like Gmail or any other .. i hope that u are expose to OOP programming in PHP
Sudantha
To install a SMTP server in ubuntu use the following command in Terminal
Sudantha
sudo apt-get install postfix
Sudantha
@Aos that should be asked on serverfault.com, not here
Pekka
@Sudantha...i have already install postfix....but still is not working...
Aos
@Aos please start providing a proper error description.
Pekka
@Aos what the error description are u getting it will help to examine the problem !
Sudantha
@Sudantha...could u please help me with ur email id...so dat i can send u the detailed description...
Aos
@Aos asking users for one-on-one E-Mail support is rude. You can provide a detailed description by editing your question here, or opening a new one on serverfault.com
Pekka
A: 

Some mailservers ( IE MailEnable ) aint handling the FROM correctly a fix would be this

$header="FROM: your name <your email>";

To

$header="FROM: your email";
A-R