<?php
/**
* the_question.php
* Created on 2006-06-26
* by
* Author: Peter Juul Jensen
*
* Description: Processing the brotherhood question
*
*/
//include standard functions and variables
include "nifconConfig.php";
include "nifconDatabaseFuncs.php";
include "passgenerator.php";
if(isset($_POST['answer']) ) {
//temp varible
$answer_to_question = $_POST['answer'];
if($answer_to_question==8){
//temp varibles
$email = $_POST['email'];
$testcase = "/^[a-z0-9]([a-z0-9_\-\.]*)@([a-z0-9_\-\.]*)(\.[a-z]{2,4}(\.[a-z]{2}){0,2})$/i";
if(preg_match($testcase,$email)){
$first_name = $_POST['first_name'];
if(strlen($first_name)<=0){
header("location: index.php?wrong=first_name");
exit;
}
$surname = $_POST['surname'];
if(strlen($surname)<=0){
header("location: index.php?wrong=surname");
exit;
}
//generating a randon username and password
$user_name = substr($first_name,0,3).substr($surname,0,3);
$password2 = gen_random_password(8);
//setting up the mail message to the user
$msg = "Welcome to the brotherhood Novice $first_name $surname \n\n\n";
$msg .= "Your secret login: \n";
$msg .= "User name: $user_name \n";
$msg .= "Password: $password2 \n\n";
$msg .= "Login here: [url]http://www.nifcon.dk/9/login.php[/url] \n\n";
$msg .= "The brotherhood watches over you \n\n\n";
$msg .= "The Grand Master \n";
$to = $email;
$subject = "Welcome to the Dark Brotherhood of Nifcon";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: Grand Master <grandmaster@nifcon.dk>\r\n";
//$mailheaders = "From: Grand Master <grandmaster@nifcon.dk>\r\n";
//sending the mail
$mail = @mail($to, $subject, $msg, $headers);
//connection to database made
$con = db_connect();
//SQL statements
$sql = "INSERT INTO nif9_person (p_ID, first_name, surname, address, zip, gender, email, phone_number, country) VALUES (NULL, '$first_name', '$surname', NULL, NULL, NULL, '$email', NULL, NULL)";
$sql2 = "INSERT INTO nif9_security (sec_ID, user_name, user_password, security_rank_ID, p_ID) VALUES (NULL,'$user_name','$password2', 1, LAST_INSERT_ID())";
//Result set from DB
$result = mysql_query($sql,$con);
$result2 = mysql_query($sql2,$con);
if(!$mail){
echo "Email not sent! Please try later...";
}else{
echo "Mail sent successfully!";
}
//header("location: login.php");
//exit;
}
else{
header("location: index.php?wrong=email");
exit;
}
}
else{
header("location: index.php?wrong=answer");
exit;
}
}
else{
header("location: index.php?wrong=answer");
exit;
}
?>
I have this code for a fictive lodge .... the problem with the code is no mail is sent ... (or the mail dont reach its goal)
if(!$mail){
echo "Email not sent! Please try later...";
}else{
echo "Mail sent successfully!";
}
return true ....
But there's no mails .... plz help :glare: