CS174
Chris Pollett
Sep 30, 2020
$_SESSION["test"]=37; /* sets the test session variable*/ echo $_SESSION["test"];
<form method="post"> <!--... some form elements --> <input type="submit" name='submit button' value='submit' /> </form>we process the data in the receiving controller. Rather than choose a view and display it, we instead, output a 301 redirect, location header to some safe page. In PHP, we could do this with a line like:
<?php header("Location:http://somewhere.safe.com/");
Models in the MVA pattern often interact with a database so we are going to have a whirlwind tour of databases to learn how to do this.
car(make VARCHAR(10), model VARCHAR(10), year DATE)
is an example table schema (specification). A possible row of car
is:
('Toyota', 'Corolla', '1970-01-01')
mysqladmin -uroot password what_password_is
mysql -uroot -pwhat_password_is
show databases;
use dbname;
show tables;
GRANT SELECT, INSERT, UPDATE, DELETE, LOCK TABLES on dbname.* TO username@127.0.0.1 IDENTIFIED BY 'password';
mysql -uusername -ppassword
CREATE DATABASE my_nifty_db;
CREATE TABLE customer ( cust_id int(5) NOT NULL, name VARCHAR(50), title CHAR(3), PRIMARY KEY(cust_id) );
DROP TABLE customer;
DROP DATABASE my_nifty_db;
select col1, col2, col3 from table1, table2, table3 where condition_holds;
/* To Get First Names and Last Names of Employees with Salary's bigger than $10000 */ SELECT FNAME, LNAME FROM EMPLOYEE WHERE SALARY > 10000;