/** * Get a requested value from either $_POST or $_GET * * @param string $key index to look for in index * @param mixed $default default value to return if key not found * @return mixed value passed in request */ public static function get($key, $default = null) { if (inputHas($key)) { return self::escape($_REQUEST[$key]); } return null; }
function inputGet($key) { if (inputHas($key)) { return $_REQUEST[$key]; } return null; }
function pageController() { $data = []; //$data['counter'] = isset($_GET["counter"]) ? $_GET["counter"] : 0; $data['counter'] = inputHas('counter') ? escape(inputGet('counter')) : 0; return $data; }
function inputGet($key) { if (inputHas($key) == true) { return $_REQUEST[$key]; } else { return null; } }
function inputGet($key) { if (inputHas($key)) { return $_REQUEST[$key]; } else { return NULL; } }
function inputGet($key) { if (inputHas($key)) { return escape($REQUEST[$key]); } else { return null; } }
function pageController() { if (inputHas('counter')) { $counter = inputGet('counter'); } else { $counter = 0; } return array('counter' => $counter); }
function pageController() { $name = ""; $password = ""; $javascript = ""; if (!empty($_POST)) { $name = inputHas('name') ? inputGet('name') : ""; $password = inputHas('password') ? inputGet('password') : ""; $javascript = ''; if (Auth::attempt($name, $password)) { header('Location: /ads.index.php'); die; } else { if ($name != "" || $password != "") { $javascript = 'alert("Incorrect input.")'; } } } return array('name' => $name, 'password' => $password, 'javascript' => $javascript); }
<?php require_once 'Order.php'; require_once 'Customer.php'; require_once 'functions.php'; if (inputHas('oderNumber')) { $customer = new Customer(); $customer->name = inputGet('customer_name'); $customer->orderNumber = inputGet('orderNumber'); $order = new Order(); $oder->orderNumber = inputGet('oderNumber'); }
function inputGet($key) { $value = inputHas($key) ? $_REQUEST[$key] : ''; return $value; }
function inputGet($key) { $result = inputHas($key) ? $_REQUEST[$key] : NULL; return $result; }
<?php session_start(); //always at the top! require_once 'functions.php'; $username = inputHas('username') ? inputGet('username') : ''; $password = inputHas('password') ? inputGet('password') : ''; $realUsername = "******"; $realPassword = "******"; //first tells me that they are logged in already and don't need to be here if (isset($_SESSION['LOGGED_IN_USER']) && $_SESSION['LOGGED_IN_USER'] != '') { header('Location: /authorized.php'); die; } else { if ($username == $realUsername && $password == $realPassword) { //create a session key, save the value as username $_SESSION['LOGGED_IN_USER'] = $username; header('Location: /authorized.php'); die; } else { if ($username != "" || $password != "") { echo "WRONG!"; } } } ?> <!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="sessions.css"> </head>
$sessionId = session_id(); require_once 'classes.php'; require_once 'classes2.php'; require_once 'functions.php'; //order form has hidden orderNumber //that submits with the form. if (inputHas('orderNumber')) { $customer = new Customer(); $order->orderNumber = inputGet('orderNumber'); $order->customer = inputGet('customer_name'); $order = new Order(); $order->deliveryAddress = inputGet('delivery_address'); $order->orderNumber = inputGet('order_number'); $order->customer = $customer; } if (inputHas('delivered')) { $order->deliver(); } ?> <!DOCTYPE html> <html> <head> <title>Stuff</title> </head> <body> <?php if ($order->delivered) { ?> <h1>Your order is here.</h1> <?php } else {
function inputGet($key) { if (inputHas($key)) { return escape($_REQUEST[$key]); } }
function inputGet($key) { $value = inputHas($key) ? $_REQUEST[$key] : ''; return escape($value); }