I'm trying to send mail with Id Number for user registering, id number inserted automatic from MySQL...
The id number is a primary key and auto increment. Its name in MySQL is 'con_id'
I tried this code:
This is a register.php code and sendmail function:
<?php
class register
{
private $con_name;
private $con_email;
private $con_cell;
private $con_password;
private $cxn;
function __construct($data)
{
if (is_array($data)) {
$this->setData($data);
}
else {
throw new Exception("register not found");
}
$this->connectToDb();
$this->registerUser();
}
private function setData($data)
{
$this->con_name = $data['con_name'];
$this->con_email = $data['con_email'];
$this->con_cell = $data['con_cell'];
$this->con_password = $data['con_password'];
}
private function connectToDb()
{
include '../models/database.php';
$vars = '../include/vars.php';
$this->cxn = new database($vars);
}
function registerUser()
{
$query = mysql_query("SELECT con_email FROM consumer WHERE con_email='$this->con_email'");
if (mysql_num_rows($query) > 0) {
header('location:../invalid-consumer.php');
}
else {
$query = "INSERT INTO `consumer`(`con_id`, `con_name`, `con_email`, `con_cell`, `con_password`) VALUES ('', '$this->con_name', '$this->con_email',
'$this->con_cell', '$this->con_password' )";
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" . "activate.php?id=" . $current_id;
$toEmail = $_POST["con_email"];
$body = $_POST["con_name"];
$subject = "User Registration Activation Email";
$content = $_POST["con_id"];
$mailHeaders = "From: Admin\r\n";
if (mail($toEmail, $subject, $content, $mailHeaders)) {
$message = "You have registered and the activation mail is sent to your email. Click the activation link to activate you account.";
}
unset($_POST);
$sql = mysql_query($query);
if ($sql)
header('location:../success.php');
else {
throw new Exception("Error not registerd");
}
}
}
function close()
{
$this->cxn->close();
}
}
?>
An email was successfully sent for a new user registered, but not the id number found or not found. Any content email is empty.
Note: The user registered will be logged in with id number only...
How can I fix this problem?