function add_user($jag)
{
    /* Set up all the variables used by the function.
       They are passed from the registration page. */
    $uname = strtolower(trim($_REQUEST['uname']));
    $alias = $uname;
    /* The passwords must match. */
    $_REQUEST['passwd'] == $_REQUEST['confirm'] ? $passwd = md5($_REQUEST['passwd']) : ($passwd = FALSE);
    $email = strtolower(trim($_REQUEST['email']));
    $sid = md5("{$_SERVER['SERVER_NAME']}:{$_SERVER['REMOTE_ADDR']}");
    if ($passwd != FALSE) {
        $result = db_addUser($uname, $passwd, $email, $alias, $sid);
        if ($result == FALSE) {
            /* Assign variables for the register form. */
            $jag->assign('uname', $uname);
            $jag->assign('email', $email);
            $jag->assign('error', 'Could not connect to the database. Please try again later.');
            $jag->assign('disp', 'register');
        } else {
            /* Registration was successful. */
            $jag->assign('disp', 'index');
        }
    } else {
        /* We didn't add the user because they missed typed their password. */
        $jag->assign('uname', $uname);
        $jag->assign('email', $email);
        $jag->assign('error', 'Passwords do not match.');
        $jag->assign('disp', 'register');
    }
}
Example #2
0
 $email_in_use = db_getUserId(null, $email, null);
 $username_in_use = db_getUserId($felh_nev, null, null);
 $card_in_use = db_getUserId(null, null, $kartyaId);
 if ($email_in_use === FALSE && $username_in_use === FALSE && $card_in_use === FALSE) {
     /* ************* HTML E-MAIL KÜLDÉSE ************* */
     $to = $email;
     $subject = "HRP Interaktív Program - Regisztráció";
     $message = "Szia!";
     $headers = "MIME-Version: 1.0" . "\r\n";
     $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
     //$headers .= 'From: <*****@*****.**>' . "\r\n";
     //$headers .= 'Cc: myboss@example.com' . "\r\n";
     mail($to, $subject, $message, $headers);
     /* *********************************************** */
     $hash = password_hash($jelszo, PASSWORD_BCRYPT, ['cost' => 10]);
     $ret1 = db_addUser($email, $felh_nev, $kartyaId, $hash, $vez_nev, $ker_nev, $elonev, $telefon, $lakhely_varos, $lakhely_varosresz);
     $stmt = $conn->prepare("UPDATE kartya SET vallalat_telephely=? WHERE kartya_id=?");
     $ret2 = $stmt->execute(array($thely, $kartyaId));
     if ($ret1 === TRUE && $ret2) {
         echo "registration_succeeded";
     } else {
         echo "registration_failed";
     }
 } else {
     if ($username_in_use !== FALSE) {
         echo "username_in_use";
     } else {
         if ($card_in_use !== FALSE) {
             echo "card_in_use";
         } else {
             echo "email_in_use";