Introduction to
ê PHP It is a
scripting language for web development.
<html>
<head>
<title>PHP
Test</title>
</head>
<body>
<?php
echo
'<p>Hello CS 476/676 Stdents</p>'; ?>
</body>
</html>
<form action="action.php"
method="post">
<p>Your
name: <input type="text" name="name"
/></p>
<p>Your age: <input type="text" name="age"
/></p>
<p>Your
password: <input type="password" name="password"
/></p>
<p><input type="submit"
/></p>
<p><input type="reset"
/></p>
</form>
Hi <?php echo $_POST['name']; ?>.
You are <?php echo (int)$_POST['age']; ?> years old. <br>
<?php echo '<br>
Data submitted:<br>'; print_r($_POST); ?>
ê JavaScript
<html>
<h1>CS 476/576 Introduction to JavaScript</h1>
<script type="text/javascript">
<!-- <![CDATA[
alert("Welcome to CS476/576 web
page!");
var userName;
userName = prompt("Please ENTER your NAME");
document.write("<h2>Hello
" + userName +
"</h2>");
var userColor;
userColor = prompt("Please TYPE the COLOR name(e.g., red, blue,
green");
document.bgColor
= userColor;
function promptAge()
{
var Age;
Age = prompt("Please ENTER your AGE ");
if (Age <= 18)
{
alert("your Age is not greater than
18.");
} else {
alert("Thank you for entering your
Age: " + Age);
}
}
// ]]> -->
</script>
<input type="button"
value="Click to enter Age" onclick="promptAge();" />
</html>
Example 2: javascriptform.html
<script type="text/javascript">
<!-- <![CDATA[
function validateForm()
{
if (document.forms[0].name.value == "" )
{
alert("Name
field cannot be empty.");
return false;
}
if (document.forms[0].age.value < 18)
{
alert("Age
is less than 18. You are not an adult.");
return false;
}
return true;
}
// ]]> -->
</script>
<head>
<title>CS
476/576 JavaScript Practice</title>
</head>
<body>
<h1>CS 476/576 JavaScript Form
Handling</h1>
<form action="action.php"
method="post" onsubmit="return validateForm() ;">
<p>Your name: <input type="text" name="name"
/></p>
<p>Your age: <input type="text" name="age"
/></p>
<p>Your
password: <input type="password" name="password"
/></p>
<p><input type="submit"
/></p>
<p><input type="reset"
/></p>
</form>
</body>
</html>