Ejemplo n.º 1
0
function checkout()
{
    global $connect;
    $ossz_ar = 0;
    $termek_szam = 0;
    $idopont = date('Y') . '/' . date('m') . '/' . date('d');
    foreach ($_SESSION['cart']['items'] as $key => $value) {
        $termek_szam++;
        $ossz_ar += $value['ar'];
    }
    $fsql = 'INSERT INTO rendeles(email, idopont, ossz_ar, termek_szam)' . ' VALUES (:email, to_date(:idopont, \'yyyy/mm/dd\'), :ossz_ar, :termek_szam)';
    $bQ = oci_parse($connect, $fsql);
    oci_bind_by_name($bQ, ':email', $_SESSION['email']);
    oci_bind_by_name($bQ, ':ossz_ar', $ossz_ar);
    oci_bind_by_name($bQ, ':idopont', $idopont);
    oci_bind_by_name($bQ, ':termek_szam', $termek_szam);
    $i = 0;
    $last = "SELECT * FROM rendeles WHERE rownum <= 1 ORDER BY rendeles_id DESC";
    $stid = oci_parse($connect, $last);
    if (!$stid) {
        $e = oci_error($connect);
        trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
    }
    $r = oci_execute($stid);
    if (!$r) {
        $e = oci_error($stid);
        trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
    }
    $row = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS);
    print_r($row);
    foreach ($_SESSION['cart']['items'] as $key => $value) {
        $i++;
        $rs = 'UPDATE rendeles_reszletei set termek_id = ' . $value['id'] . ', darab_szam = 1, termek_ar = ' . $value['ar'] . ' where rendeles_id = ' . $row['RENDELES_ID'] . ' AND termek_id = ' . $i;
        $rq = oci_parse($connect, $rs);
        oci_execute($rq);
    }
    if (oci_execute($bQ)) {
        clearcart();
        $_SESSION['cart']['items'] = array();
        //echo '<script type="text/javascript">window.location.href="../index.php";</script>';
    }
}
Ejemplo n.º 2
0
/**
 * Felhasználó bejelentkeztetését és a
 * Session lekezelését elvégző metódus
 */
function login_check()
{
    error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
    session_start();
    require_once "php/connection.php";
    if (!$_POST["email"] || !$_POST["jelszo"]) {
        $errorMessage = "Nem adtad meg az emailt/jelszot!";
        header("location:../login.php?Error=" . $errorMessage);
    } else {
        $email = $_POST["email"];
        $jelszo = $_POST["jelszo"];
        $tbl_name = "felhasznalo";
        $sql = oci_parse($connect, "select * from felhasznalo where email = '" . addslashes($_POST["email"]) . "' and jelszo = '" . addslashes($_POST["jelszo"]) . "'");
        oci_execute($sql);
        while ($row = oci_fetch_array($sql, OCI_BOTH)) {
            $_SESSION['email'] = $row[0];
            $_SESSION['nev'] = $row[2];
            $_SESSION['szul_ido'] = $row[3];
            $_SESSION['telefon'] = $row[5];
            $_SESSION['egyenleg'] = $row[6];
            $_SESSION['reg_datum'] = $row[7];
            $_SESSION['torzsvasarlo'] = $row[8];
        }
        require_once 'cart.php';
        clearcart();
        $_SESSION['cart']['items'] = array();
        if ($_SESSION['email']) {
            $tipus = "felhasznalo";
            $_SESSION['tipus'] = $tipus;
            header("Location:profile.php");
        } else {
            echo '<script type="text/javascript">
			alert("Hibás email/jelszó ");
			window.location.href="/netshop/login.php";</script>';
        }
    }
}