Created
April 29, 2020 09:23
-
-
Save prensmiskin/a6e8f2c7ffbfacf5bc4316b8610875a4 to your computer and use it in GitHub Desktop.
Sahnarts APP / Register web servis kodları. Kayıt olunduğunda otomatik bir şekilde onay maili gidiyor giden mail'le tıknanıldığında giriş yapabiliyor.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use PHPMailer\PHPMailer\PHPMailer; | |
use PHPMailer\PHPMailer\Exception; | |
require 'PHPMailer/src/Exception.php'; | |
require 'PHPMailer/src/PHPMailer.php'; | |
require 'PHPMailer/src/SMTP.php'; | |
if($_SERVER['REQUEST_METHOD']=='POST'){ | |
$usernamee = $_POST["username"]; | |
$maill = $_POST["mail"]; | |
$passwordt = $_POST["password"]; | |
$code = rand(10000,100000); | |
$durum = 0; | |
$servername = "delete"; | |
$username = "delete"; | |
$password = "delete"; | |
$dbname = "delete"; | |
try { | |
$conn = new PDO("mysql:host=$servername;dbname=$dbname;charset=utf8", $username, $password); | |
// set the PDO error mode to exception | |
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
$v = $conn->prepare("select * from register where mail=? || username=?"); | |
$v->execute(array($maill, $usernamee)); | |
$x = $v->fetch(PDO::FETCH_ASSOC); | |
$d = $v->rowCount(); | |
if( $d){ | |
$result["success"] = 2; | |
echo json_encode($result); | |
}else{ | |
$sql = "INSERT INTO register (username,mail,password,code,durum) | |
VALUES ('$usernamee','$maill', '$passwordt','$code','$durum')"; | |
// use exec() because no results are returned | |
$conn->exec($sql); | |
if ($conn){ | |
$result["success"] = 36; | |
echo json_encode($result); | |
$mail = new PHPMailer(); | |
$mail->isSMTP(); | |
$mail->SMTPDebug = 2; | |
$mail->SMTPKeepAlive = true; | |
$mail->SMTPAuth = ssl; | |
$mail->SMTPSecure = 'ssl'; //ssl | |
$mail->Port = 465; //25 , 465 , 587 | |
$mail->Host = "smtp.gmail.com"; | |
$mail->Username = "delete"; | |
$mail->Password = "delete"; | |
$mail->setFrom("0delete"); | |
$mail->addAddress($maill); | |
$mail->isHTML(true); | |
$mail->Subject = "Sahnarts Mail Onay Kodu"; | |
$mail->Body = "<h4>MERHABA <strong style='color: blue;'>$usernamee</strong> | |
<br> | |
Sahnarts ÜYELİĞİNİZİ DOĞRULAMAK İÇİN LÜTFEN TIKLAYINIZ.</h4></br> | |
<br> | |
<a href='https://goldgym.pro/aktifet.php?mail=$maill&code=$code'>Aktif Et</a> | |
</br> | |
<br> | |
<br> | |
<br> | |
<img style='max-width: 100%; | |
height: auto;'; src='https://user-images.githubusercontent.com/40228440/78979280-323b2f00-7b24-11ea-9d98-5d654748fc0f.jpg' alt='sahnarts' width='50%' height='50%'> | |
"; | |
//$mail->addAttachment("dosya.txt"); | |
/* Mail gönderildiyse */ | |
if ($mail->send()){ | |
$result["success"] = 45; | |
echo json_encode($result); | |
}else{ | |
$result["success"] = 40; | |
echo json_encode($result); | |
} | |
} | |
} | |
}//TRY | |
catch(PDOException $e) | |
{ | |
echo $sql . "<br>" . $e->getMessage(); | |
} | |
$conn = null; | |
}//POST | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment