update
1.COOKIES
=> SETTING A COOKIE
Syntax :
Set-cookie:NAME=value;EXPIRES=date;PATH=path;DOMAIN=domain;SECURE
The NAME=value is the only required piece of information that must be included in the set-cookie field .
All other entries are optional.
Example :
<html>
<head>
<script>
function newcookie(cookiename, value)
{
document.cookie=cookiename+"="+value;
}
</script>
</head>
<body>
<script>
document.write('<form>');
document.write('<table border="0" width="100%">');
document.write('<tr>');
document.write('<td width="25%">First Name</td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td width="25%">First Name</td>');
document.write('<td width="25%">
<input type="text" name="first_nm" onBlur="newcookie(this.name,this.value);"
Size="20" type="text" value="'+cfirst_nm+'">
</td>');
document.write('</td>');document.write('</tr>');
document.write('</table>');
document.write('</form>');
</script>
</body>
</html>
2.VALIDATION
2.1 Field Name cannot be left empty
------------------------------
/* Cheking if the variable for Client's name is empty,(i.e.a blank Client's name field was submitted .) */
if(empty($_POST['txtName']))
{
/*returning data entry form if the Client's name is empty.*/
$alertmessage="<center>
Filed for Client\'s Name is empty!
</center>";
inclide("page2.php");
exit;
}
2.2 No double spacing in the field name captured
-----------------------------------------
=> To test double spacing validation,insert double spaces in between the Client Name and click submit button .
=> The PHP code checks the contents of Client Name field returned by the Browser. As it has double spacing,an error message is generated and stored in the variable $alertmessage.
ereg("([[:space:]]{2})",$_POST["txtName"]);
------------------------------------------------------------------------------
else
{
if(ereg("([[:space:]]{2})",$_POST["txtName"]))
{
/*
returning data entry form if the Client's name contains double spaces.
*/
$alertmessage="<center>
Double spaces found in Client\'s Name!
</center>";
inclide("page2.php");
exit;
}
}
--------------------------------------------------------------------------------------------------------
2.VALIDATION
2.1 Field Name cannot be left empty
2.1 Field Name cannot be left empty
------------------------------
/* Cheking if the variable for Client's name is empty,(i.e.a blank Client's name field was submitted .) */
if(empty($_POST['txtName']))
{
/*returning data entry form if the Client's name is empty.*/
$alertmessage="<center>
Filed for Client\'s Name is empty!
</center>";
inclide("page2.php");
exit;
}
2.2 No double spacing in the field name captured
-----------------------------------------
=> To test double spacing validation,insert double spaces in between the Client Name and click submit button .
=> The PHP code checks the contents of Client Name field returned by the Browser. As it has double spacing,an error message is generated and stored in the variable $alertmessage.
ereg("([[:space:]]{2})",$_POST["txtName"]);
------------------------------------------------------------------------------
else
{
if(ereg("([[:space:]]{2})",$_POST["txtName"]))
}
--------------------------------------------------------------------------------------------------------
if(empty($_POST['txtName']))
{
/*returning data entry form if the Client's name is empty.*/
$alertmessage="<center>
Filed for Client\'s Name is empty!
</center>";
inclide("page2.php");
exit;
}
2.2 No double spacing in the field name captured
-----------------------------------------
=> To test double spacing validation,insert double spaces in between the Client Name and click submit button .
=> The PHP code checks the contents of Client Name field returned by the Browser. As it has double spacing,an error message is generated and stored in the variable $alertmessage.
ereg("([[:space:]]{2})",$_POST["txtName"]);
------------------------------------------------------------------------------
else
{
if(ereg("([[:space:]]{2})",$_POST["txtName"]))
{
/*
returning data entry form if the Client's name contains double spaces.
*/
$alertmessage="<center>
Double spaces found in Client\'s Name!
</center>";
inclide("page2.php");
exit;
}
--------------------------------------------------------------------------------------------------------
1 comment:
Good
Post a Comment