Local Konumu: AppServ/www/mailactive < aynı veritabanı (tablo ise members)
index.php:
include "connect.php";
if(isset($_POST['reg'])){
require_once "mail/class.phpmailer.php";
$name = $_POST['name'];
$mail = $_POST['pass'];
$pass = $_POST['pass'];
$passmd = md5($pass);
$active = uniqid(prefix: 'deneme');
if(!$name || !$mail || !$pass){
echo "Fill!";
}else{
if(!filter_var($mail, filter: FILTER_VALIDATE_EMAİL)){
echo "mail problem!";
}else{
//reg need perm = 2
//reg with =1 it was permed
$register = $db->prepare( statement: "INSERT INTO members SET
name =:n,
mail =:m,
pass =:p,
active =:a,
perm =:r
");
$register->execute([':n'=>$name,':m'=>$mail,':p'=>$passmd,':a'=>$active,':r'=>2]);
if($register){
$mail = new PHPMailer();
$mail-> Host = "smtp.yandex.com";
$mail-> Port = 587; //ssl for 465 ssl not 587
$mail-> SMTPSecure = 'tls'; //if ssl direct wrote / if empty tls will..
$mail-> SMTPAuth = true; //will not change
$mail-> Username = "admin@admin.com" ;
$mail-> Password = "deneme";
$mail-> IsSMTP();
$mail-> AddAddress($mail);
$mail-> From = "admin@admin.com";
$mail-> FromName = "Account Verification";
$mail-> CharSet = "UTF-8";
$mail-> Subject = "Activation Link";
$activationlink = "http://localhost/mailactive/activation.php?code=".$activationlink;
$mailcontent = " Activation link : ".$activationlink."";
$mail-> MsgHTML($mailcontent);
if($mail->Send()){
echo "Mail activation is sended!";
}else{
echo "Error!";
}
}else{
echo "Fail!";
}
}
}
?>
connect.php:
try{
$db=new PDO("mysql:host=localhost;dbname=mailactive;charset=utf8",'root','12345678');
echo "u did it bro"
}
catch (PDOException $error){
print_r($error->getMessage());
}
?>