Wednesday, June 29, 2016

HTML basic 6

Animation for Games!
<!DOCTYPE html>
<html>
<head>
 <meta charset="utf-8" />
 <script src="bucky.js"></script>
</head>
<body>
 <section id="main">
 <canvas id="canvas" width="600" height="400">
 hopefully you dont see this. if you do, get google chrome
 </canvas>
 </section>
</body>
</html>

Bucky.JS
function doFirst(){
 var x = document.getElementById('canvas');
 canvas=x.getContext('2d');
 window.addEventListener("mousemove", bucky, false);
}
function bucky(e){
 // canvas.clearRect(0, 0, 600, 400);
 var xPos=e.clientX;
 var yPos=e.clientY;
 canvas.fillRect(xPos-10, yPos-10, 20, 20);
}
window.addEventListener("load", doFirst, false);

Drag and Drop
<!DOCTYPE html>
<html>
<head>
 <meta charset="utf-8" />
 <link rel="stylesheet" href="bucky.css">
 <script src="bucky2.js"></script>
</head>
<body>
 <section id="leftbox">
 I dare you to drag an image in me!
 </section>
 <section id="rightbox">
  <img id="facepic" width="120" height="150" src="images/myface.png">
 </section>
</body>
</html>

bucky.css:
#leftbox{
 float:left;
 width:250px;
 height: 250px;
 margin: 5px;
 border: 3px solid blue;
}
#rightbox{
 float:left;
 width:250px;
 height: 250px;
 margin: 5px;
 border: 3px solid green;
}

bucky2.js:
function doFirst(){
 mypic = document.getElementById('facepic');
 mypic.addEventListener("dragstart", startDrag, false);
 leftbox=document.getElementById('leftbox');
 leftbox.addEventListener("dragenter", function(e){ e.preventDefault();}, false);
 leftbox.addEventListener("dragover", function(e){ e.preventDefault();}, false);
 leftbox.addEventListener("drop", dropped, false);
}
function startDrag(e){
 var code='<img id="facepic" width="120" height="150" src="images/myface.png">';
 e.dataTransfer.setData('Text', code);
}
function dropped(e){
 e.preventDefault();
 leftbox.innerHTML = e.dataTransfer.getData('Text');
}
window.addEventListener("load", doFirst, false);
\

HTML basic 5

Playing Video:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
</head>
<body style="background-color:#8EE5EE;">
<div id="box">
<video src="videos/34.mp4" width="640" height="360" poster="images/myface.png"
autoplay loop controls > </video>
</div>
</body>
</html>

Animation and Transition
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="new.css">
</head>
<body>
<div id="box">
<p id="text">omgwtfbbq</p>
</div>
</body>
</html>

New.css:
body{
text-align: center;
}
#box{
display: block;
width: 500px;
margin: 150px auto;
padding: 15px;
text-align: center;
border: 7px solid blue;
background: yellow;
-webkit-transition: -webkit-transform 1s;
}
#box:hover{
-webkit-transform:rotate(45deg);

}

Awesome Rollover Buttons:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="new.css">
</head>
<body>
<div id="box">
<p id="text">omgwtfbbq</p>
</div>
</body>
</html>
New.css:
#box {
        -webkit-border-radius: 10px;
-webkit-transition-property: background-color, width, opacity, height, -webkit-transform;
-webkit-transition-duration: 1s, 1s, 1s, 1s, 1s;
-webkit-transition-timing-function: linear, ease-in, ease-in, ease-in, ease-in;


}

#box:hover {
opacity: 1.0;
background: orange;
width: 200px;
height: 120px;
-webkit-transform: rotate(360deg);
}

HTML and CSS Basic 4

Flexible:
Index.html

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Hello World</title>
<link rel="stylesheet" href="main2.css">
</head>
<body>
<div id="big_wrapper">
<header id="top_header">
<h1>Welcome to thenewboston!</h1>
</header>

<nav id="top_menu">
<ul>
<li>Home</li>
<li>Tutorial</li>
<li>Podcast</li>
</ul>
</nav>

<div id="new_div">

<section id="main_section">
<article>
<header>
<hgroup>
<h1>Title of article</h1>
<h2>Subtitle for article</h2>
    </hgroup>
</header>
         <p>This is the best article eva!</p>
<footer>
<p> written by Zoloo</p>
</footer>
</article>
<article>
<header>
<hgroup>
<h1>Title of article 2</h1>
<h2>Subtitle for article 2</h2>
</hgroup>
</header>
<p>This is the best article eva!</p>
<footer>
<p> written by Zoloo</p>
</footer>
</article>

</section>
<aside id="side_news">
<h4>News</h4>
Bucky has a new dog!
</aside>
</div>
<footer id="the_footer">
Copyright thenewboston 2011
</footer>
</div>
</body>
</html>

Main2.css
*{
margin:0px;
padding: 0px;
}
h1{ font: bold 20px Tahoma; }
h2{ font: bold 14px Tahoma; }
header, section, footer, aside, nav, article, hgroup{
display:block;
}
body{
width: 100%;
display: -webkit-box;
-webkit-box-pack: center;
}
#big_wrapper{
max-width:1000px;
margin: 20px 0px;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-box-flex: 1;
}
#top_header{
background: yellow;
border: 3px solid black;
padding: 20px;
}
#top_menu{
border: red;
background:blue;
color: white;
}
#top_menu li {
display: inline-block;
list-style: none;
padding: 5px;
font: bold 14px Tahoma;
}
#new_div{
display: -webkit-box;
-webkit-box-orient: horizontal;
}
#main_section{
border: 1px solid blue;
-webkit-box-flex: 1;
margin: 20px;
padding:20px;
}
#side_news{
border: 1px solid red;
width: 220px;
margin: 20px 0px;
padding: 30px;
background: #66CCCC;
}
#the_footer{
text-align: center;
padding:20px;
border-top: 2px solid green;
}

Sunday, June 12, 2016

HTML and CSS Basic 3

INDEX.HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Hello World</title>
<link rel="stylesheet" href="main.css">
</head>
<body>
<div id="big_wrapper">
<header id="top_header">
<h1>Welcome to thenewboston!</h1>
</header>

<nav id="top_menu">
<ul>
<li>Home</li>
<li>Tutorial</li>
<li>Podcast</li>
</ul>
</nav>
<section id="main_section">
<article>
<header>
<hgroup>
<h1>Title of article</h1>
<h2>Subtitle for article</h2>
</hgroup>
</header>
<p>This is the best article eva!</p>
<footer>
<p> written by Zoloo</p>
</footer>
</article>
<article>
<header>
<hgroup>
<h1>Title of article 2</h1>
<h2>Subtitle for article 2</h2>
</hgroup>
</header>
<p>This is the best article eva!</p>
<footer>
<p> written by Zoloo</p>
</footer>
</article>

</section>
<aside id="side_news">
<h4>News</h4>
Bucky has a new dog!
</aside>
<footer id="the_footer">
Copyright thenewboston 2011
</footer>
</div>
</body>
</html>

MAIN.CSS
*{
margin:0px;
padding:0px;
}
h1{
font: bold 20px Tahoma;
}
h2{
font: bold 14px Tahoma;
}
header, section, footer, aside, nav, article, hgroup{
display:block;
}
body{
text-align:center;
}
#big_wrapper{
border: 1px solid black;
width:1000px;
margin:20px auto;
text-align:left;
}
#top_header{
background:yellow;
border: 1px solid blue;
padding: 20px;
}
#top_menu{
background:blue;
color: white;
}
#top_menu li{
display:inline-block;
list-style:none;
padding:5px;
font: bold 14px Tahoma;
}
#main_section{
float:left;
width: 660px;
margin:30px;
}
#side_news{
float:left;
width:220px;
margin:20px 0px;
padding: 30px;
background: #66CCCC;
}
#the_footer{
clear:both;
text-align:center;
padding: 20px;
border-top:2px solid green;
}
article{
background:#FFFBCC;
border:1px solid red;
padding:20px;
margin-bottom:10px;
}
article footer{
text-align:right;
}

Wednesday, June 8, 2016

HTML basic 2

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
<title>Page Title</title>
</head>
<body>
<form>
Username: <input type="text" name="username" size="20" value="Enter name here" />
<br>
Male: <input type="radio" name="sex" value="male" />
Female: <input type="radio" name="sex" value="female" />
<p>Select the foods that you would like to order!</p>
Bacon <input type="checkbox" name="sex" value="bacon" />
Ham <input type="checkbox" name="sex" value="ham" />
Tuna <input type="checkbox" name="sex" value="tuna" />
Soda Pop <input type="checkbox" name="sex" value="sodapop" />
<br>
<br>
What car do you want?
<select name="cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="fiat">Fiat</option>
<option value="audi">Audi</option>
</select>
<br>
This is textarea:<br>
<textarea name="message" rows="5" cols="30">
The cat was playing in the garden.
</textarea>
<br>
Password: <input type="password" name="pword" />
<p>Now submit a file! </p>
<input type="file" name="buckyfile" />
</form>
</body>
</html>

Monday, June 6, 2016

HTML basic 1

<!DOCTYPE html>
<html>
<head>
<title> This is the title </title>
</head>

<body>
<strong> Im in the body </strong>
<hr/>
<p><em> This is paragraph </em></p>
<!-- this is comment -->
This will be a <a href="second.html">link</a>
<br><a href="mailto:zooljaboy@yahoo.com" title = "this is tip">Email Zoloo</a><br>
<img src="http://www.w3schools.com/images/w3schools_green.jpg" alt="W3Schools.com" width="160" height="128">
<br>

<!-- TABLE -->
<table border="1">
<tr>
<th>A team</th>
<th>B team</th>
<th>C team</th>
</tr>
<tr>
<td>Atlanta</td>
<td>Boston</td>
<td>Chicago</td>
</tr>
<tr>
<td>New York</td>
<td>Miami</td>
<td>Indiana</td>
</tr>
<tr>
<td>Washington</td>
<td>Portland</td>
<td>New Orlean</td>
</tr>
</table>

<br>
<table border="1" cellspacing="10">
<tr>
<th colspan="2"><h3>NBA all star</h3></th>
</tr>
<tr>
<th>East</th>
<th>West</th>
</tr>
<tr>
<td>Miami</td>
<td>Indiana</td>
</tr>
<tr>
<td>Portland</td>
<td>New Orlean</td>
</tr>
</table>

<!-- LIST -->
<br>
<ul>
<li>Point Guard</li>
<li>Shooting Guard</li>
<li>Small Forward</li>
<li>Power Forward</li>
<li>Center</li>
</ul>
<ol>
<li>Point Guard</li>
<li>Shooting Guard</li>
<li>Small Forward</li>
<li>Power Forward</li>
<li>Center</li>
</ol>
</body>
</html>

Sunday, May 29, 2016

PHP Tutorial 12

Logging the User In Out:
Index.php
<?php
require 'core.inc.php';
require 'connect.inc.php';

if (loggedin()) {
            echo 'You\'re logged in.<a href="logout.php">Log out</a>';
} else {
                        include 'loginform.inc.php';    
}

?>

Loginform.inc.php
<?php
if(isset($_POST['username']) && isset($_POST['password'])){
            $username=$_POST['username'];
            $password=$_POST['password'];
            $password2 = md5($password);
            if(!empty($username) && !empty($password)){
                        $query="SELECT id FROM users WHERE username='".$username."' AND password='".$password2."'";
                       
                        if($query_run = mysqli_query($mysql_conn,$query)){
                                    $query_num_rows=mysqli_num_rows($query_run);
                                    if($query_num_rows==0){
                                                echo 'Invalid username/password combination.';
                                    } else if($query_num_rows==1) {
                                                // echo 'OK';
                                      $user_id=mysqli_fetch_array($query_run);
                                       extract($user_id);
                                       $_SESSION['user_id']=$user_id;
                                       header('Location: Tutorial2.php');
                                    }
                        }
            } else {
                        echo 'You must supply a username and password';
            }
}
?>

<form action="<?php echo $current_file; ?>" method="POST">
Username: <input type="text" name="username"><br><br>
Password: <input type="password" name="password"><br>
<input type="submit" value="Log in">
</form>

Core.inc.php
<?php
ob_start();
session_start();
$current_file = $_SERVER['SCRIPT_NAME'];
@$http_referer = $_SERVER['HTTP_REFERER'];
function loggedin(){
                if(isset($_SESSION['user_id']) && !empty($_SESSION['user_id']))
                                return true;
                return false;
}
?>

Logout.php
<?php
require 'core.inc.php';
session_destroy();
header('Location: '.$http_referer);

?>