@Kar92

Mail функция всегда отправляет в одну и тот же email, то есть сохраняет в сибе первый email и всегда отправляет в ниго. «Помогите» пожалуйсто?

<?php

require "vendor/autoload.php";

require 'init.php';

class Register {

    private $license_key;
    private $activation;

    function Register()
    {
        $firebase = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN);

        if (isset($_POST['submitter'])) {


            $this->activation = false;
            $id = uniqid();
            $this->license_key = uniqid();
            $oneYearOn = date('Y-m-d', strtotime(date("Y-m-d", mktime()) . " + 365 day"));

            $activation_url = uniqid();
            $firebase->set(DEFAULT_PATH . "/ARCusers/$id/login", $_POST['addlogin']);
            $firebase->set(DEFAULT_PATH . "/ARCusers/$id/password", $_POST['addpassword']);
            $firebase->set(DEFAULT_PATH . "/ARCusers/$id/email", $_POST['addemail']);
            $firebase->set(DEFAULT_PATH . "/ARCusers/$id/activation", $this->activation);
            $firebase->set(DEFAULT_PATH . "/ARCusers/$id/License/license key", $this->license_key);
            $firebase->set(DEFAULT_PATH . "/ARCusers/$id/License/license key activation", $this->activation = false);
            $firebase->set(DEFAULT_PATH . "/ARCusers/$id/License/license key date", $oneYearOn);


            $email = $_POST['addemail'];
           
            $subject = "Confirm";
            $text = "for confirm registration follow this link http://firebase.dev/$activation_url.php";
            $headers = "From: karenshahmradyan@gmail.com" . "\r\n";
            mail($email, $subject, $text, $headers);


            $body = '<?php 
        require "vendor/autoload.php";
const DEFAULT_URL = \'https://test-272e7.firebaseio.com/\';
const DEFAULT_TOKEN = \'Ebxl8gukFiptEZahmC1HeJVUT9dcRTTkzyPrmeqo\';
const DEFAULT_PATH = \'\';

$firebase = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN);
$json = $firebase->get(DEFAULT_PATH . "/ARCusers/", array(\'activation\' => \'"true"\'));


$json = json_decode($json,true);
foreach($json as $key=>$val);

    
$firebase->set(DEFAULT_PATH . "/ARCusers/$key/activation", true);
echo "Your email is verified";
' . "unlink('$activation_url');
        unlink(\"$activation_url.php\");";


            $fcount = fopen("$activation_url", "a+");
            $fp = fopen("$activation_url.php", "a+");
            fwrite($fp, $body);
            fclose($fp);
            fwrite($fcount, '');
            fclose($fcount);


        }
    }

}


?>




<!DOCTYPE HTML>
<html>
<head>
    <title>Firebase</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link href="css/style.css" rel="stylesheet">
</head>
<body>



<form class="pure-form" method="post">

    <h2>Registration</h2>

    <input name="addlogin" placeholder="Type your login" type="text">
    <br><br><br>
    <input name="addpassword" placeholder="Type your password" type="password">
    <br><br><br>
    <input name="addemail" placeholder="Type your email address" type="text">
    <br><br><br>
    <button type="submit" onclick="<?php $registration = new Register(); ?>" name="submitter" class="pure-button pure-button-primary">
        Register
    </button>

    <br>
    <hr>
    <br>

</form>

</body>
</html>
  • Вопрос задан
  • 219 просмотров
Пригласить эксперта
Ответы на вопрос 1
@metnee
<!DOCTYPE HTML>
<html>
<head>
    <title>Firebase</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link href="css/style.css" rel="stylesheet">
</head>
<body>

<?php new Register(); ?>

<form class="pure-form" method="post">

    <h2>Registration</h2>

    <input name="addlogin" placeholder="Type your login" type="text">
    <br><br><br>
    <input name="addpassword" placeholder="Type your password" type="password">
    <br><br><br>
    <input name="addemail" placeholder="Type your email address" type="text">
    <br><br><br>
    <button type="submit" name="submitter" class="pure-button pure-button-primary">
        Register
    </button>
    <br>
    <hr>
    <br>

</form>

</body>
</html>
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы