Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Apress
committed
Oct 19, 2016
0 parents
commit 5b3e7cb
Showing
117 changed files
with
10,419 additions
and
0 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
print "Hello World!"; | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
function getXMLHttp() | ||
{ | ||
var xmlHttp; | ||
try | ||
{ | ||
xmlHttp = new XMLHttpRequest(); | ||
} | ||
catch(e) | ||
{ | ||
//Internet Explorer is different than the others | ||
try | ||
{ | ||
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); | ||
} | ||
catch(e) | ||
{ | ||
try | ||
{ | ||
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); | ||
} | ||
catch(e) | ||
{ | ||
alert("Old browser? Upgrade today so you can use AJAX!") | ||
return false; | ||
} | ||
} | ||
} | ||
return xmlHttp; | ||
} | ||
function AjaxRequest() | ||
{ | ||
var xmlHttp = getXMLHttp(); | ||
xmlHttp.onreadystatechange = function() | ||
{ | ||
if(xmlHttp.readyState == 4) | ||
{ | ||
HandleResponse(xmlHttp.responseText); | ||
} | ||
} | ||
xmlHttp.open("GET", "myfirstprogram.php", true); | ||
xmlHttp.send(null); | ||
} | ||
function HandleResponse(response) | ||
{ | ||
document.getElementById('AjaxResponse').innerHTML = response; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||
<html> | ||
<head> <title>PHP Ajax Demo</title> | ||
<meta charset="utf-8"> | ||
<link href="e23ajaxdemo.css" rel="stylesheet"> | ||
<script type='text/javascript' src='e21Ajax_Example_JavaScript.js'></script> | ||
</head> | ||
<body> | ||
<div id="wrapper"> | ||
<div id="header"> <h1>PHP Ajax Demo</h1> </div> | ||
<div id="content"> <h2>"Watch it!!"</h2> | ||
<p>The words below will be replaced by "Hello World" which is pulled from the 'myfirstprogram.php' file via AJAX.</p> | ||
<h2>AJAX DEMO</h2> | ||
<input type='button' onclick='AjaxRequest();' value='Find Hello World!'/><br /><br /> | ||
<div id='AjaxResponse'> | ||
Pay attention... Notice when you click the button that only this section changes. | ||
</div> </div> <!-- end of content --> | ||
<div id="footer">Copyright © 2014 Steve Prettyman | ||
</div><!-- end of footer --> | ||
</div> <!-- end of wrapper --> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
body { background-color: #000000; | ||
font-family: Arial, Verdana, sans-serif; } | ||
#wrapper { margin: 0 auto; | ||
width: 85%; | ||
min-width: 800px; | ||
background-color: #cc0000; | ||
color: #000066; } | ||
#header { background-color: #ff0000; | ||
color: #00005D; | ||
font-size: 125%; | ||
padding: 20px 20px 20px 160px; | ||
background-repeat: no-repeat; } | ||
h1 { margin-bottom: 10px; } | ||
#content { background-color: #ffffff; | ||
color: #000000; | ||
padding: 10px 20px; | ||
overflow: auto; } | ||
#footer { font-size: 80%; | ||
text-align: center; | ||
padding: 5px; | ||
background-color: #0000FF; | ||
color: #ffffff; | ||
clear: both;} | ||
h2 { color: #000000; | ||
font-family: Arial, sans-serif; } | ||
#floatright { float: right; | ||
margin: 10px; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||
<head> <title>PHP Ajax Demo</title> | ||
<meta charset="utf-8"> | ||
<link href="e23ajaxdemo.css" rel="stylesheet"> | ||
<link href="e24ajaxdemomobile.css" rel="stylesheet" media="only screen and (max-device-width:480px)"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<script type='text/javascript' src='e21Ajax_Example_JavaScript.js'></script> | ||
</head> | ||
<body> | ||
<div id="wrapper"> | ||
<div id="header"> <h1>PHP Ajax Demo</h1> </div> | ||
<div id="content"> <h2>"Watch it!!"</h2> | ||
<p>The words below will be replaced by "Hello World" which is pulled from the 'myfirstprogram.php' file via AJAX.</p> | ||
<h2>AJAX DEMO</h2> | ||
<input type='button' onclick='AjaxRequest();' value='Find Hello World!'/><br /><br /> | ||
<div id='AjaxResponse'> | ||
Pay attention... Notice when you click the button that only this section changes. | ||
</div> </div> <!-- end of content --> | ||
<div id="footer">Copyright © 2014 Steve Prettyman | ||
</div><!-- end of footer --> | ||
</div> <!-- end of wrapper --> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
body { background-color: #000000; | ||
font-family: Arial, Verdana, sans-serif; | ||
margin: 0; } | ||
#wrapper { margin: 0 auto; | ||
width: 100%; | ||
margin: 0; | ||
min-width: 0px; | ||
background-color: #cc0000; | ||
color: #000066; } | ||
#header { background-color: #ff0000; | ||
color: #00005D; | ||
font-size: 100%; | ||
padding: 0.5px 0.5px 0.5px 0.5px; } | ||
h1 { margin: 0px; } | ||
#content { background-color: #ffffff; | ||
color: #000000; | ||
padding: 0.5px 0.5px; | ||
overflow: auto; } | ||
#footer { font-size: 80%; | ||
text-align: left; | ||
padding: 0px; | ||
background-color: #0000FF; | ||
color: #ffffff; | ||
clear: both;} | ||
h2 { color: #000000; | ||
font-family: Arial, sans-serif; | ||
margin: 0px; } | ||
#floatright { float: none; | ||
margin: 0px; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
print '<html>'; | ||
print '<head><title>My Program</title></head>'; | ||
print '<body>'; | ||
print '<h1>Hello World</h1>'; | ||
print '</body>'; | ||
print '</html>'; | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
if (isset($_POST['submitbutton'])) | ||
{ | ||
print "<h1> Hello World </h1>"; | ||
} | ||
else | ||
{ | ||
print "<html><head><title>PHP Example</title></head>"; | ||
print "<form method='post' action='e26callmyself.php'>"; | ||
print "<input type='submit' id='submitbutton' name='submitbutton' value='Find Hello World!'/>"; | ||
print "</form>"; | ||
print "</body></html>"; | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
class Dog | ||
{ | ||
// ----------------------------------------- Properties ----------------------------------------- | ||
private $dog_weight = 0; | ||
private $dog_breed = "no breed"; | ||
private $dog_color = "no color"; | ||
private $dog_name = "no name"; | ||
|
||
// ---------------------------------- Set Methods ---------------------------------------------- | ||
function set_dog_name($value) | ||
{ | ||
$error_message = TRUE; | ||
(ctype_alpha($value) && strlen($value) <= 20) ? $this->dog_name = $value : $error_message = FALSE; | ||
return $error_message; | ||
} | ||
function set_dog_weight($value) | ||
{ | ||
$error_message = TRUE; | ||
(ctype_digit($value) && ($value > 0 && $value <= 120)) ? $this->dog_weight = $value : $error_message = FALSE; | ||
return $error_message; | ||
} | ||
function set_dog_breed($value) | ||
{ | ||
$error_message = TRUE; | ||
(ctype_alpha($value) && strlen($value) <= 35) ? $this->dog_breed = $value : $error_message = FALSE; | ||
return $error_message; | ||
} | ||
function set_dog_color($value) | ||
{ | ||
$error_message = TRUE; | ||
(ctype_alpha($value) && strlen($value) <= 15) ? $this->dog_color = $value : $error_message = FALSE; | ||
return $error_message; | ||
} | ||
// ----------------------------------------- Get Methods ------------------------------------------------------------ | ||
function get_dog_name() | ||
{ | ||
return $this->dog_name; | ||
} | ||
function get_dog_weight() | ||
{ | ||
return $this->dog_weight; | ||
} | ||
function get_dog_breed() | ||
{ | ||
return $this->dog_breed; | ||
} | ||
function get_dog_color() | ||
{ | ||
return $this->dog_color; | ||
} | ||
function get_properties() | ||
{ | ||
return "$this->dog_weight,$this->dog_breed,$this->dog_color."; | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
Require_once("e310dog.php"); | ||
$lab = new Dog; | ||
// ------------------------------Set Properties-------------------------- | ||
$dog_error_message = $lab->set_dog_name('Fred'); | ||
print $dog_error_message == TRUE ? 'Name update successful<br/>' : 'Name update not successful<br/>'; | ||
|
||
$dog_error_message = $lab->set_dog_weight(50); | ||
print $dog_error_message == TRUE ? 'Weight update successful<br />' : 'Weight update not successful<br />'; | ||
|
||
$dog_error_message = $lab->set_dog_breed('Lab'); | ||
print $dog_error_message == TRUE ? 'Breed update successful<br />' : 'Breed update not successful<br />'; | ||
|
||
$dog_error_message = $lab->set_dog_color('Yellow'); | ||
print $dog_error_message == TRUE ? 'Color update successful<br />' : 'Color update not successful<br />'; | ||
// ------------------------------Get Properties-------------------------- | ||
print $lab->get_dog_name() . "<br/>"; | ||
print $lab->get_dog_weight() . "<br />"; | ||
print $lab->get_dog_breed() . "<br />"; | ||
print $lab->get_dog_color() . "<br />"; | ||
$dog_properties = $lab->get_properties(); | ||
list($dog_weight, $dog_breed, $dog_color) = explode(',', $dog_properties); | ||
print "Dog weight is $dog_weight. Dog breed is $dog_breed. Dog color is $dog_color."; | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
class Dog | ||
{ | ||
// ----------------------------------------- Properties ----------------------------------------- | ||
private $dog_weight = 0; | ||
private $dog_breed = "no breed"; | ||
private $dog_color = "no color"; | ||
private $dog_name = "no name"; | ||
private $error_message = "??"; | ||
// ---------------------------------- Constructor ---------------------------------------------- | ||
function __construct($value1, $value2, $value3, $value4) | ||
{ | ||
|
||
$name_error = $this->set_dog_name($value1) == TRUE ? 'TRUE,' : 'FALSE,'; | ||
$breed_error = $this->set_dog_breed($value2) == TRUE ? 'TRUE,' : 'FALSE,'; | ||
$color_error = $this->set_dog_color($value3) == TRUE ? 'TRUE,' : 'FALSE,'; | ||
$weight_error= $this->set_dog_weight($value4) == TRUE ? 'TRUE' : 'FALSE'; | ||
|
||
$this->error_message = $name_error . $breed_error . $color_error . $weight_error; | ||
|
||
} | ||
//------------------------------------toString-------------------------------------------------- | ||
public function __toString() | ||
{ | ||
return $this->error_message; | ||
} | ||
|
||
// ---------------------------------- Set Methods ---------------------------------------------- | ||
function set_dog_name($value) | ||
{ | ||
$error_message = TRUE; | ||
(ctype_alpha($value) && strlen($value) <= 20) ? $this->dog_name = $value : $this->error_message = FALSE; | ||
return $this->error_message; | ||
} | ||
function set_dog_weight($value) | ||
{ | ||
$error_message = TRUE; | ||
(ctype_digit($value) && ($value > 0 && $value <= 120)) ? $this->dog_weight = $value : $this->error_message = FALSE; | ||
return $this->error_message; | ||
} | ||
function set_dog_breed($value) | ||
{ | ||
$error_message = TRUE; | ||
(ctype_alpha($value) && strlen($value) <= 35) ? $this->dog_breed = $value : $error_message = FALSE; | ||
return $this->error_message; | ||
} | ||
function set_dog_color($value) | ||
{ | ||
$error_message = TRUE; | ||
(ctype_alpha($value) && strlen($value) <= 15) ? $this->dog_color = $value : $this->error_message = FALSE; | ||
return $this->error_message; | ||
} | ||
// ----------------------------------------- Get Methods ------------------------------------------------------------ | ||
function get_dog_name() | ||
{ | ||
return $this->dog_name; | ||
} | ||
function get_dog_weight() | ||
{ | ||
return $this->dog_weight; | ||
} | ||
function get_dog_breed() | ||
{ | ||
return $this->dog_breed; | ||
} | ||
function get_dog_color() | ||
{ | ||
return $this->dog_color; | ||
} | ||
function get_properties() | ||
{ | ||
return "$this->dog_weight,$this->dog_breed,$this->dog_color."; | ||
} | ||
|
||
|
||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
Require_once("e312dog.php"); | ||
$lab = new Dog('Fred','Lab','Yellow','100'); | ||
|
||
list($name_error, $breed_error, $color_error, $weight_error) = explode(',', $lab); | ||
|
||
print $name_error == 'TRUE' ? 'Name update successful<br/>' : 'Name update not successful<br/>'; | ||
print $breed_error == 'TRUE' ? 'Breed update successful<br/>' : 'Breed update not successful<br/>'; | ||
print $color_error == 'TRUE' ? 'Color update successful<br/>' : 'Color update not successful<br/>'; | ||
print $weight_error == 'TRUE' ? 'Weight update successful<br/>' : 'Weight update not successful<br/>'; | ||
|
||
// ------------------------------Set Properties-------------------------- | ||
$dog_error_message = $lab->set_dog_name('Sally'); | ||
print $dog_error_message == TRUE ? 'Name update successful<br/>' : 'Name update not successful<br/>'; | ||
|
||
$dog_error_message = $lab->set_dog_weight('5'); | ||
print $dog_error_message == TRUE ? 'Weight update successful<br />' : 'Weight update not successful<br />'; | ||
|
||
$dog_error_message = $lab->set_dog_breed('Labrador'); | ||
print $dog_error_message == TRUE ? 'Breed update successful<br />' : 'Breed update not successful<br />'; | ||
|
||
$dog_error_message = $lab->set_dog_color('Brown'); | ||
print $dog_error_message == TRUE ? 'Color update successful<br />' : 'Color update not successful<br />'; | ||
// ------------------------------Get Properties-------------------------- | ||
print $lab->get_dog_name() . "<br/>"; | ||
print $lab->get_dog_weight() . "<br />"; | ||
print $lab->get_dog_breed() . "<br />"; | ||
print $lab->get_dog_color() . "<br />"; | ||
$dog_properties = $lab->get_properties(); | ||
list($dog_weight, $dog_breed, $dog_color) = explode(',', $dog_properties); | ||
print "Dog weight is $dog_weight. Dog breed is $dog_breed. Dog color is $dog_color."; | ||
?> |
Oops, something went wrong.