LookitsPuck
April 26th, 2004, 10:32 PM
Okay, here's my code for my site:
<?php
if (!empty($_POST['userEmail']) && !empty($_POST['userName']))
{
setcookie("UName", $_POST['userName'], time()+36000);
setcookie("UEmail", $_POST['userEmail'], time()+36000);
}
?>
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head><title>movie reviews main page | stephen paul adams</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css"
href="ext.css"/>
<SCRIPT language="JavaScript">
<!--
function ValidDecimal(strString)
{
var strValidChars = "0123456789.-";
var strChar;
var blnResult = true;
if (strString.length == 0)
return false;
// test strString consists of valid characters listed above
for (i = 0; i < strString.length && blnResult == true; i++)
{
strChar = strString.charAt(i);
if (strValidChars.indexOf(strChar) == -1)
blnResult = false;
}
return blnResult;
}
function ValidateInsert()
{
x=document.insert;
movieN=x.movName.value;
movieT=x.movType.value;
movieRa=x.movRating.value;
movieRe=x.movReview.value;
movieI=x.movIncome.value;
submit="True";
if (movieN == "")
{
alert("You must enter a movie name!");
submit="False";
}
if (movieT == "")
{
alert("You must enter a movie type!");
submit="False";
}
if (movieRa == "")
{
alert("You must enter a movie rating");
submit="False";
}
if (!ValidDecimal(movieI))
{
alert("You must enter a valid dollar value!");
submit="False";
}
if (movieRe == "")
{
alert("You must enter a movie review!");
submit="False";
}
if (submit == "False")
return false;
else
return true;
}
// -->
</SCRIPT>
</head>
<body>
<div id = "banner">
<?php
if (isset($_COOKIE["UName"]))
echo "Welcome " . $_COOKIE["UName"] . "!<br/>";
else
echo "You are not logged in! No cookies set.<br/>";
?>
</div>
<div id = "left">
<br/>
<img src = "update.jpg" alt = "update"/><br/>
update an existing movie review<br/>
<form action = "update.php" name = "update" method ="post" id="updateform">
What movie ID is it that you'd like to change?<br/>
<input type = "text" name = "movID" size = "20" maxlength = "5"/><br/><br/>
What movie information would you like to change?<br/>
Title<input type="checkbox" name="movies0" value="title"/><br/>
Type <input type="checkbox" name="movies1" value="type"/><br/>
Rating <input type="checkbox" name="movies2" value="rating"/><br/>
Income <input type="checkbox" name="movies3" value="income"/><br/>
Review <input type="checkbox" name="movies4" value="review"/><br/>
<input type = "submit" value = "continue"/><br/>
</form>
</div>
<div id = "leftcenter">
<br/>
<img src = "insert.jpg" alt = "insert"/><br/>
insert a movie review<br/>
<form action="movieinsert.php" name = "insert" method="post" id="insertform" onsubmit="return ValidateInsert
()">
Movie's Name: <br/>
<input type = "text" name = "movName" size = "20" maxlength = "70"/><br/><br/>
Movie Type: <br/>
horror, comedy, romance, etc. <br/>
<input type = "text" name = "movType" size = "20" maxlength = "20"/><br/><br/>
Movie Rating: <br/>
G, PG, PG-13, R, NC-17;<br/>
<input type = "text" name = "movRating" size = "20" maxlength = "5"/><br/><br/>
Movie Income: <br/>
<input type = "text" name = "movIncome" size = "20" maxlength = "13"/><br/><br/>
Movie Review: <br/>
Poor, Good, Very Good, Excellent<br/>
<input type = "text" name="movReview" size = "20" maxlength = "20"/><br/><br/>
<input type = "submit" value = "submit movie review"/><br/>
</form>
</div>
<div id = "rightcenter">
<br/>
<img src = "view.jpg" alt = "view"/><br/>
<a href = "database.php">view movie reviews</a><br/>
</div>
<div id = "right">
<br/>
<img src = "delete.jpg" alt = "delete"/><br/>
delete one of your movie reviews<br/>
*has to be YOUR movie review<br/>
*cookies must be set in order to delete<br/>
*view movie database to obtain movie ID<br/><br/><br/>
<form action="moviedelete.php" name = "delete" method="post" id="deleteform">
<input type = "text" name = "movID" size = "20" maxlength = "20"/><br/><br/>
<input type = "submit" value = "delete movie review"/><br/>
</form>
</div>
</body>
</html>
And here's the link:
http://triton.towson.edu/~sadams10/finalproject/fpmain.php
Anyways, I have the Javascript verification done for the insert mechanism. The problem lies in verifying the Update and Delete mechanisms. For some reasons, the form data isn't being set at all. This was the code I was using:
function ValidateDelete()
{
x=document.delete;
id=x.movID.value;
if(!ValidDecimal(id))
{
alert("Not a valid id value.");
return false;
}
else
return true;
}
Now, if I put that function in my file, I get a Javascript error about expected identifiers and whatnot. I don't know why it's not working, as the ValidateInsert() function works correctly and it uses similar syntax.
Any help?
-Steve
***EDIT I've changed the site, so now I have the ValidateDelete() inside it as well as have the onsubmit="return ValidateDelete" inside the form for the delete section. You should be able to see the error that I'm getting [expected identifier].
Thanks all
-Steve
<?php
if (!empty($_POST['userEmail']) && !empty($_POST['userName']))
{
setcookie("UName", $_POST['userName'], time()+36000);
setcookie("UEmail", $_POST['userEmail'], time()+36000);
}
?>
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head><title>movie reviews main page | stephen paul adams</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css"
href="ext.css"/>
<SCRIPT language="JavaScript">
<!--
function ValidDecimal(strString)
{
var strValidChars = "0123456789.-";
var strChar;
var blnResult = true;
if (strString.length == 0)
return false;
// test strString consists of valid characters listed above
for (i = 0; i < strString.length && blnResult == true; i++)
{
strChar = strString.charAt(i);
if (strValidChars.indexOf(strChar) == -1)
blnResult = false;
}
return blnResult;
}
function ValidateInsert()
{
x=document.insert;
movieN=x.movName.value;
movieT=x.movType.value;
movieRa=x.movRating.value;
movieRe=x.movReview.value;
movieI=x.movIncome.value;
submit="True";
if (movieN == "")
{
alert("You must enter a movie name!");
submit="False";
}
if (movieT == "")
{
alert("You must enter a movie type!");
submit="False";
}
if (movieRa == "")
{
alert("You must enter a movie rating");
submit="False";
}
if (!ValidDecimal(movieI))
{
alert("You must enter a valid dollar value!");
submit="False";
}
if (movieRe == "")
{
alert("You must enter a movie review!");
submit="False";
}
if (submit == "False")
return false;
else
return true;
}
// -->
</SCRIPT>
</head>
<body>
<div id = "banner">
<?php
if (isset($_COOKIE["UName"]))
echo "Welcome " . $_COOKIE["UName"] . "!<br/>";
else
echo "You are not logged in! No cookies set.<br/>";
?>
</div>
<div id = "left">
<br/>
<img src = "update.jpg" alt = "update"/><br/>
update an existing movie review<br/>
<form action = "update.php" name = "update" method ="post" id="updateform">
What movie ID is it that you'd like to change?<br/>
<input type = "text" name = "movID" size = "20" maxlength = "5"/><br/><br/>
What movie information would you like to change?<br/>
Title<input type="checkbox" name="movies0" value="title"/><br/>
Type <input type="checkbox" name="movies1" value="type"/><br/>
Rating <input type="checkbox" name="movies2" value="rating"/><br/>
Income <input type="checkbox" name="movies3" value="income"/><br/>
Review <input type="checkbox" name="movies4" value="review"/><br/>
<input type = "submit" value = "continue"/><br/>
</form>
</div>
<div id = "leftcenter">
<br/>
<img src = "insert.jpg" alt = "insert"/><br/>
insert a movie review<br/>
<form action="movieinsert.php" name = "insert" method="post" id="insertform" onsubmit="return ValidateInsert
()">
Movie's Name: <br/>
<input type = "text" name = "movName" size = "20" maxlength = "70"/><br/><br/>
Movie Type: <br/>
horror, comedy, romance, etc. <br/>
<input type = "text" name = "movType" size = "20" maxlength = "20"/><br/><br/>
Movie Rating: <br/>
G, PG, PG-13, R, NC-17;<br/>
<input type = "text" name = "movRating" size = "20" maxlength = "5"/><br/><br/>
Movie Income: <br/>
<input type = "text" name = "movIncome" size = "20" maxlength = "13"/><br/><br/>
Movie Review: <br/>
Poor, Good, Very Good, Excellent<br/>
<input type = "text" name="movReview" size = "20" maxlength = "20"/><br/><br/>
<input type = "submit" value = "submit movie review"/><br/>
</form>
</div>
<div id = "rightcenter">
<br/>
<img src = "view.jpg" alt = "view"/><br/>
<a href = "database.php">view movie reviews</a><br/>
</div>
<div id = "right">
<br/>
<img src = "delete.jpg" alt = "delete"/><br/>
delete one of your movie reviews<br/>
*has to be YOUR movie review<br/>
*cookies must be set in order to delete<br/>
*view movie database to obtain movie ID<br/><br/><br/>
<form action="moviedelete.php" name = "delete" method="post" id="deleteform">
<input type = "text" name = "movID" size = "20" maxlength = "20"/><br/><br/>
<input type = "submit" value = "delete movie review"/><br/>
</form>
</div>
</body>
</html>
And here's the link:
http://triton.towson.edu/~sadams10/finalproject/fpmain.php
Anyways, I have the Javascript verification done for the insert mechanism. The problem lies in verifying the Update and Delete mechanisms. For some reasons, the form data isn't being set at all. This was the code I was using:
function ValidateDelete()
{
x=document.delete;
id=x.movID.value;
if(!ValidDecimal(id))
{
alert("Not a valid id value.");
return false;
}
else
return true;
}
Now, if I put that function in my file, I get a Javascript error about expected identifiers and whatnot. I don't know why it's not working, as the ValidateInsert() function works correctly and it uses similar syntax.
Any help?
-Steve
***EDIT I've changed the site, so now I have the ValidateDelete() inside it as well as have the onsubmit="return ValidateDelete" inside the form for the delete section. You should be able to see the error that I'm getting [expected identifier].
Thanks all
-Steve