• 30-03-2020, 04:44:07
    #1
    Merhabalar,
    Çok araştırdım ama bulamadım, üyelik formum var bununla ilgili telefon numarasına bir sms gitmesini ve sisteme giriş yapmasını doğruysa giriş yapmasını istiyorum çözemedim yardımcı olurmusunuz ?

    netgsm api

    function SMSgonderHttpGET(){
    $username = "s"; //
    $telno = $_POST["telnoonay"]; //
    $password = urlencode("s"); //
    $mesaj = rand(1,999999); //
    
    $url= "https://api.netgsm.com.tr/sms/send/get/?usercode=$username&password=$password&gsmno=$telno&message=172721&msgheader=baslik";
    
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    $http_response = curl_exec($ch);
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    
    if($http_code != 200){
    echo "$http_code $http_response\n";
    return false;
    }
    $balanceInfo = $http_response;
    echo "MesajID : $balanceInfo";
    return $balanceInfo;
    }
    
    SMSgonderHttpGET();
     try
    {
    
    $connect = new PDO("mysql:host=$host; dbname=$database", $username, $password);
    $connect->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    if(isset($_POST["login"]))
    {
    if(empty($_POST["username"]) || empty($_POST["password"]))
    {
    $message = '<label>All fields are required</label>';
    }
    else
    {
    $query = "SELECT * FROM from_veritabani WHERE kullaniciadi = :username AND kullanicisifre = :password";
    $statement = $connect->prepare($query);
    $statement->execute(
    array(
    'username' => $_POST["username"],
    'password' => $_POST["password"]
    
    )
    
    
    );
    
    $count = $statement->rowCount();
    if($count > 0)
    {
    $_SESSION["username"] = $_POST["username"];
    $_SESSION["password"] = $_POST["password"];
    header("location:index.php");
    
    }
    else
    {
    $message = '<label>Wrong Data</label>';
    }
    
    }
    
    }
    
    }
    catch(PDOException $error)
    {
    $message = $error->getMessage();
    }
    buda formum

     <form class="form-horizontal m-t-20" method="POST">
    
    <div class="form-group ">
    <div class="col-xs-12">
    <input class="form-control" type="text" required="" name="username" required placeholder="Kullanıcı Adı">
    </div>
    </div>
    <div class="form-group ">
    <div class="col-xs-12">
    <input class="form-control" type="text" required="" name="telnoonay" required placeholder="Kullanıcı Adı">
    </div>
    </div>
    
    <div class="form-group">
    <div class="col-xs-12">
    <input class="form-control" type="text" id='textbox' required="" name="password" required placeholder="***********">
    </div>
    </div>
    
    
    
    <div class="form-group text-center m-t-40">
    <div class="col-xs-12">
    <button class="btn btn-pink btn-block text-uppercase waves-effect waves-light" type="submit" name="login">Giriş Yap</button>
    </div>
    </div>
    
    <div class="form-group m-t-30 m-b-0">
    <div class="col-sm-12">
    <i class="fa fa-lock m-r-5"></i> 
    </div>
    </div>
                </form>
  • 30-03-2020, 04:50:33
    #2
    SMSgonderHttpGET fonksiyonunun kullanımı hatalı. Bu şekilde $_POST dan gelen telefon numarası verisini çekemez.

    SMSgonderHttpGET($_POST["telnoonay"]); şeklinde kullanman lazım.
    Eksik var kodlarında. Adım adım gitmen lazım
    • Fes
    Fes bunu beğendi.
    1 kişi bunu beğendi.
  • 30-03-2020, 22:20:04
    #3
    Yardımcı olabilecek varmı.
  • 30-03-2020, 23:19:54
    #4
    Bayağı bir kırptım ama yolu gösterir diye düşünüyorum

    /* kayitdogrulama.php */
    session_start();
    if(
    isset($_POST['telnoonay']) && strlen(trim($_POST['telnoonay'])) == 10 &&
    isset($_POST['username']) && trim($_POST['username']) != '' &&
    isset($_POST['password']) && trim($_POST['password']) != ''
    ){
    
    $_SESSION['ykpasswd'] = $_POST['password'];
    $_SESSION['ykuname'] = $_POST['username'];
    $_SESSION['yktel'] = $_POST['telnoonay'];
    $smsuser = 'smsusername';
    $smspasswd = 'smspasswd';
    /// Kullanıcı var mı? varsa kayıt etmeyeceğiz. Buradaki kodu size bırakıyorum
    if(!$kayitli){
    $_SESSION['ccode'] = rand(100000, 999999);
    $url= 'https://api.netgsm.com.tr/sms/send/get/?usercode='.$smsuser
    .'&password='.$smspasswd
    .'&gsmno='.$tel
    .'&message='.$_SESSION['ccode'].'&msgheader=Dogrulama%20Kodunuz';
    // Buradaki değerler demo amaçlı. Kullandığınız servis json formatında cevap vermiyor olabilir
    $dk = json_parse(file_get_contents($url), true);
    if($dk['status'] == 1){
    // Gönderilen şifrenin girileceği form
    header("location: smsdogrula.php");
    }else{
    
    header("location: index.php?hata=SMS gönderilemedi");
    }
    }else{
    session_destroy();
    header("location: giris.php?hata=kayitliuye");
    
    }
    }else{
    session_destroy();
    }
    /* --------------------------------------- */
    
    // smsdogula.php
    
    session_start();
    $hatakodu = 'koyok';
    if(isset($_POST['kod']) && strlen(trim($_POST['kod'])) == 6){
    if($_POST['kod'] == $_SESSION['ccode']){
    /* Kişi telefonu doğruladı kayıdı yapıyoruz */
    
    }else{
    $hatakodu = 'kodyanlis';
    }
    
    }
    // Bir hata var. aynı sayfay geri gönderiyoruz
    header("location: smsdogrula.php?hatakodu=".$hatakodu);