Ejemplo n.º 1
0
function logout()
{
    global $todoUrl, $user;
    // delete cookies
    setcookie('todotxt-user', '', time() - 3600);
    setcookie('todotxt-pass', '', time() - 3600);
    session_unset();
    displayform(0);
    exit;
}
Ejemplo n.º 2
0
function processForm()
{
    if (!empty($_POST['nombre']) && !empty($_POST['apellidos'])) {
        displayGeneroForm($_POST['nombre'], $_POST['apellidos']);
    } else {
        $message = "";
        $message .= empty($_POST['nombre']) ? "El nombre no ha sido introducido correctamente<br>" : "";
        $message .= empty($_POST['apellidos']) ? "El apellido no ha sido introducido correctamente<br>" : "";
        displayform($message);
    }
}
Ejemplo n.º 3
0
function displayFormElements($message)
{
    $elementos = $_POST['elementos'];
    if (is_array($elementos) && checkEmptyForm($elementos)) {
        displayform("");
        $suma = 0;
        echo 'El vector tiene ' . count($elementos) . ' elementos<br>';
        for ($i = 0; $i < count($elementos); $i++) {
            echo "{$i} = {$elementos[$i]}" . '<br>';
            $suma += $elementos[$i];
        }
        echo "La suma es: {$suma}";
    } else {
        displayForm("Error!! No todos los campos del array son correctos!");
        displayElements(count($elementos));
    }
}
Ejemplo n.º 4
0
}
</style>
</head>
<body>
<pre> <?php 
//print_r($_GET)
?>
</pre>

<?php 
if (isset($_GET['submitted'])) {
    $continent = $_GET['continents'];
    //handleform($continent);
    displayContinentInfo($continent);
}
displayform("continents");
?>

<?php 
//Handle form creates query, retrieves values
function handleform($continent)
{
    $dbc = connectToDB();
    $query = "SELECT SUM( InternetUsers ) AS users, SUM( InternetHosts ) AS \nhosts , AVG( MedianAge ) AS age\nFROM countries where Continent='{$continent}' \nGROUP BY Continent";
    $result = performQuery($dbc, $query);
    $row = mysqli_fetch_array($result, MYSQLI_ASSOC);
    $users = $row['users'];
    $hosts = $row['hosts'];
    $age = $row['age'];
    $hostperuser = $users / $hosts;
    //echo  "<pre>"; print_r($row); echo "</pre>";
Ejemplo n.º 5
0
</body>
</html>
HTML;
    exit;
}
session_start();
if (!isset($_SESSION['authenticated'])) {
    if (isset($_COOKIE['todotxt-user']) && isset($_COOKIE['todotxt-pass'])) {
        if ($_COOKIE['todotxt-user'] == $user && $_COOKIE['todotxt-pass'] == md5($password)) {
            $_SESSION['authenticated'] = 1;
            header("Location:" . $_SERVER['PHP_SELF']);
        } else {
            displayform(1);
        }
    } elseif (isset($_POST['loginbutton'])) {
        if ($_POST['input_user'] == $user && $_POST['input_password'] == $password) {
            if (isset($_POST['rememberme'])) {
                /* set cookie to last 1 month */
                $expire = time() + 60 * 60 * 24 * 30;
                setcookie('todotxt-user', $_POST['input_user'], $expire);
                setcookie('todotxt-pass', md5($_POST['input_password']), $expire);
            }
            $_SESSION['authenticated'] = 1;
            header("Location:" . $todoUrl);
        } else {
            displayform(1);
        }
    } else {
        displayform(0);
    }
}
Ejemplo n.º 6
0
<!DOCTYPE html>
<head>
	<html lang="en">
	<meta charset="UTF-8">
	<title>Home Page</title>
	<link rel="stylesheet" href="css/styling.css" />
</head>
<body>
<?php 
displayform();
?>

<?php 
//Displays initial homepage with information
function displayform()
{
    ?>
<center><h1>Welcome to Movement</h1>
<fieldset>
Movement is a club for dance enthusiasts of all levels and styles.<br/><br/>

Attend classes in ballet, jazz, tap, hiphop, lyrical, point, salsa, merengue and more!
Join us on trips to see the Boston Ballet Company at the Opera House.<br/><br/>

Celebrate movement through dance with us and let's get jiggy with it!
</fieldset><br/>
<img src="img/dance.jpg" alt="Dancer" height=500 width=400 /><br />

<br/>

<!-- Join Button -->
Ejemplo n.º 7
0
	<meta charset="UTF-8" />
	<title>MySQL and PHP </title>
	<style type = "text/css">		  
			body {font-family: Verdana, sans-serif;}
	</style>
</head>
<body>
<pre><?php 
print_r($_GET);
?>
</pre>
<?php 
if (isset($_GET['formsubmitted'])) {
    handleform("studentmenu");
}
displayform("studentmenu");
?>
	
</body>
</html>
<?php 
function handleform($id)
{
    $dbc = connect_to_db("jed");
    $query = "select lastname, firstname, major from student where ID='{$id}'";
    $result = perform_query($dbc, $query);
    $row = mysqli_fetch_array($result, MYSQLI_ASSOC);
    print_r($row);
    $firstname = $row['firstname'];
    $lastname = $row['lastname'];
    $major = $row['major'];
Ejemplo n.º 8
0
echo findkelvin($xml);
echo "<br/>";
echo highestbp($xml);
echo "<br/>";
?>
</fieldset>

<?php 
if (isset($_GET['formsubmitted'])) {
    // I only handle the form if the user submitted it
    $chosenatom = $_GET['atommenu'];
    handleform($xml, $atomicnumber, $atomicweight);
} else {
    $chosenatom = "";
}
displayform($xml);
?>
	

</body>
</html>

<?php 
function findgasses($xml)
{
    $GAS = $xml->xpath('ATOM[@STATE="GAS"]');
    $str = "";
    foreach ($GAS as $g) {
        if ($str == "") {
            $str = $g->NAME;
        } else {
Ejemplo n.º 9
0
    $getHash->bind_result($hash);
    $getHash->fetch();
    $getHash->close();
    //PLEASE NOTE: the database stored string includes algo, random salt, and hash
    if (password_verify($_POST['password'], $hash)) {
        success($mysqli, $_POST['username'], $userTable);
    } else {
        displayform("Incorect Password");
    }
} else {
    if ($_POST['request'] == 'signup') {
        if ($userExists) {
            displayform("That user name is already taken");
        }
        //do we want min pass length,  if used uncommnet global variable up above
        /*    if(strlen($_POST['password']) < $minPassLength) {
                echo "Password must be at least $minPassLength long";
                exit();
            }*/
        //PLEASE NOTE: the returned string includes algo, random salt, and hash
        $hashp = password_hash($_POST['password'], PASSWORD_DEFAULT);
        //add user to database
        $addUser = $mysqli->prepare("INSERT INTO \n        {$userTable} ( username, password) \n        VALUES (?,?)");
        $addUser->bind_param("ss", $_POST['username'], $hashp);
        if (!$addUser->execute()) {
            displayform("We cannot perform that action right now");
        }
        $addUser->close();
        success($mysqli, $_POST['username'], $userTable);
    }
}
Ejemplo n.º 10
0

         <div class='row'>
        	<div class='col-md-3'></div>
        	<div class='col-md-6'>
        	<h3></h3>
          <form method="post" action='update.php'>
		  <?php 
include_once 'dbconfig.php';
//get the name
$name;
if ($_SERVER["REQUEST_METHOD"] == "GET") {
    $x = $_GET['id'];
    //this name is used to display filled form in first part and
    // to update the required row in the second part.
    displayform($x);
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $productname = $_POST["productname"];
    $productcategory = $_POST["productcategory"];
    $productprice = $_POST["productprice"];
    $hiddenname = $_POST["hiddenname"];
    updateproduct($hiddenname, $productname, $productcategory, $productprice);
}
function updateproduct($hiddenname, $productname, $productcategory, $productprice)
{
    //$name=$GLOBALS['name'];
    $sql = "UPDATE products SET product_name='{$productname}',product_category='{$productcategory}', product_price='{$productprice}' WHERE product_id='{$hiddenname}'";
    if ($GLOBALS['con']->query($sql) === TRUE) {
        echo "Record updated successfully";
        header('Location: index.php');