tags:

views:

53

answers:

3

Below is the Code

<?
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";

    // 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: 

In your line $tbl_name=temp_members_db; -- is temp_members_db a constant defined (via define('temp_members_db','some_value') in config.php? Or is it supposed to be a string? Or is it a variable name? This might be a problem you overlook ...

Konrad Neuwirth
A: 

add those lines to the top of your code:

ini_set('diplay_errors', 'on');
error_reporting(-1);

You will see the reason why nothing is displayed.

Additionally, add echo mysql_error() to see info about query errors:

$result=mysql_query($sql);
echo mysql_error();

Is temp_members_db a constant? If not, wrap into quotes:

'temp_members_db'
Silver Light
A: 

Make sure to use full <?php tag and enable error reporting. Once enabled, see what it says. Since there is no indication of what is in config.php, there could be several problems with above code:

  1. What is $tbl_name=temp_members_db;? I guess it shoud be $tbl_name = 'temp_members_db';.
  2. Are $_POST values set?
  3. Is SQL connection open?

But please, make sure to provide more information in future.

David Kuridža