mehidy
03-03-2011, 11:18 AM
Hi every one
I have search over internet & found a script which will help me to achieve my goal. Please see below script & advise is this script is ok or not?
I need your help to input data in to mysql table after completing all the verification. Cause in this script its only showing the verification but not show the process of inserting data in to mysql table after verification.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1251">
<style>
.errText {
font-family: Arial;
font-size: 10px;
color: #CC0000;
text-decoration: none;
font-weight: normal;
}
</style>
<title></title>
</head>
<?php
$errName = "";
$errAddress = "";
$errEmail = "";
$errPassport = "";
$errPhone = "";
$errZip = "";
$errDate = "";
$errUser = "";
$errPass = "";
if($_POST["ac"]=="login"){
// Full Name must be letters, dash and spaces only
if(preg_match("/^[aA-zZ][a-zA-Z -]+$/", $_POST["name"]) === 0)
$errName = '<p class="errText">Name must be from letters, dashes, spaces, must start with capital letters and must not start with dash</p>';
// Address must be word characters only
if(preg_match("/^[a-zA-Z0-9 _.,:\"\']+$/", $_POST["address"]) === 0)
$errAddress = '<p class="errText">Address must be only letters, numbers or one of the following ". , : /"</p>';
// Email mask
if(preg_match("/^[a-zA-Z]\w+(\.\w+)*\@\w+(\.[0-9a-zA-Z]+)*\.[a-zA-Z]{2,4}$/", $_POST["email"]) === 0)
$errEmail = '<p class="errText">Email must comply with this mask: chars(.chars)@chars(.chars).chars(2-4)</p>';
// Passport must be only digits
if(preg_match("/^\d{10}$|^\d{12}$/", $_POST["passport"]) === 0)
$errPassport = '<p class="errText">Passport must be 10 or 12 digits</p>';
// Phone mask 1-800-998-7087
if(preg_match("/^\d{1}-\d{3}-\d{3}-\d{4}$/", $_POST["phone"]) === 0)
$errPhone = '<p class="errText">Phone must comply with this mask: 1-333-333-4444</p>';
// Zip must be 4 digits
if(preg_match("/^\d{4}$/", $_POST["zip"]) === 0)
$errZip = '<p class="errText">Zip must be 4 digits</p>';
// Date mask YYYY-MM-DD
if(preg_match("/^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}$/", $_POST["date"]) === 0)
$errDate = '<p class="errText">Date must comply with this mask: YYYY-MM-DD</p>';
// User must be digits and letters
if(preg_match("/^crossmerkajal2011$|^mehidy1$|^mehidy2$|^mehidy3$|^mehidy4$|^mehidy5$/", $_POST["user"]) === 0)
$errUser = '<p class="errText">User must be bigger that 5 chars and contain only digits, letters and underscore</p>';
// Password must be strong
//if(preg_match("/^.*(?=.{8,})(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).*$/", $_POST["pass"]) === 0)
if(preg_match("/^.*(?=.{8,})(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).*$/", $_POST["pass"]) === 0)
$errPass = '<p class="errText">Password must be at least 8 characters and must contain at least one lower case letter, one upper case letter and one digit</p>';
}
?>
<body>
<center>
<form name="main" action="<?php $PHP_SELF ?>" method="POST">
<input type="hidden" name="ac" value="login">
<table width="500" border="0" cellpadding="4" cellspacing="0" bordercolor="#000000" bgcolor="#EDEFF1">
<tr align="center">
<td colspan="2"><strong style="font-size:18px">Field Verification</strong><br>by <a href="http://www.mehidy.com" target="_blank">mehidy.com</a></td>
</tr>
<tr align="center" bgcolor="#FD9003">
<td colspan="2" bgcolor="#A6B39D">Registration Form</td>
</tr>
<tr>
<td>Full Name:</td>
<td>
<input name="name" type="text" size="50" maxlength="100" value="<?php echo $_POST["name"]; ?>">
<?php if(isset($errName)) echo $errName; ?>
</td>
</tr>
<tr>
<td>Address:</td>
<td>
<input name="address" type="text" size="50" maxlength="250" value="<?php echo $_POST["address"]; ?>">
<?php if(isset($errAddress)) echo $errAddress; ?>
</td>
</tr>
<tr>
<td>Email:</td>
<td>
<input name="email" type="text" size="50" value="<?php echo $_POST["email"]; ?>">
<?php if(isset($errEmail)) echo $errEmail; ?>
</td>
</tr>
<tr>
<td>Passport:</td>
<td>
<input name="passport" type="text" size="16" maxlength="12" value="<?php echo $_POST["passport"]; ?>">
<?php if(isset($errPassport)) echo $errPassport; ?>
</td>
</tr>
<tr>
<td>Phone:</td>
<td>
<input name="phone" type="text" size="16" value="<?php echo $_POST["phone"]; ?>">
<?php if(isset($errPhone)) echo $errPhone; ?>
</td>
</tr>
<tr>
<td>Zip code:</td>
<td>
<input name="zip" type="text" size="16" value="<?php echo $_POST["zip"]; ?>">
<?php if(isset($errZip)) echo $errZip; ?>
</td>
</tr>
<tr>
<td>Date:</td>
<td>
<input name="date" type="text" size="16" value="<?php echo $_POST["date"]; ?>">
<?php if(isset($errDate)) echo $errDate; ?>
</td>
</tr>
<tr>
<td>Username:</td>
<td>
<input name="user" type="text" size="16" value="<?php echo $_POST["user"]; ?>">
<?php if(isset($errUser)) echo $errUser; ?>
</td>
</tr>
<tr>
<td>Password:</td>
<td>
<input name="pass" type="password" size="16" value="<?php echo $_POST["pass"]; ?>">
<?php if(isset($errPass)) echo $errPass; ?>
</td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>
</center>
</body>
</html>
I have search over internet & found a script which will help me to achieve my goal. Please see below script & advise is this script is ok or not?
I need your help to input data in to mysql table after completing all the verification. Cause in this script its only showing the verification but not show the process of inserting data in to mysql table after verification.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1251">
<style>
.errText {
font-family: Arial;
font-size: 10px;
color: #CC0000;
text-decoration: none;
font-weight: normal;
}
</style>
<title></title>
</head>
<?php
$errName = "";
$errAddress = "";
$errEmail = "";
$errPassport = "";
$errPhone = "";
$errZip = "";
$errDate = "";
$errUser = "";
$errPass = "";
if($_POST["ac"]=="login"){
// Full Name must be letters, dash and spaces only
if(preg_match("/^[aA-zZ][a-zA-Z -]+$/", $_POST["name"]) === 0)
$errName = '<p class="errText">Name must be from letters, dashes, spaces, must start with capital letters and must not start with dash</p>';
// Address must be word characters only
if(preg_match("/^[a-zA-Z0-9 _.,:\"\']+$/", $_POST["address"]) === 0)
$errAddress = '<p class="errText">Address must be only letters, numbers or one of the following ". , : /"</p>';
// Email mask
if(preg_match("/^[a-zA-Z]\w+(\.\w+)*\@\w+(\.[0-9a-zA-Z]+)*\.[a-zA-Z]{2,4}$/", $_POST["email"]) === 0)
$errEmail = '<p class="errText">Email must comply with this mask: chars(.chars)@chars(.chars).chars(2-4)</p>';
// Passport must be only digits
if(preg_match("/^\d{10}$|^\d{12}$/", $_POST["passport"]) === 0)
$errPassport = '<p class="errText">Passport must be 10 or 12 digits</p>';
// Phone mask 1-800-998-7087
if(preg_match("/^\d{1}-\d{3}-\d{3}-\d{4}$/", $_POST["phone"]) === 0)
$errPhone = '<p class="errText">Phone must comply with this mask: 1-333-333-4444</p>';
// Zip must be 4 digits
if(preg_match("/^\d{4}$/", $_POST["zip"]) === 0)
$errZip = '<p class="errText">Zip must be 4 digits</p>';
// Date mask YYYY-MM-DD
if(preg_match("/^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}$/", $_POST["date"]) === 0)
$errDate = '<p class="errText">Date must comply with this mask: YYYY-MM-DD</p>';
// User must be digits and letters
if(preg_match("/^crossmerkajal2011$|^mehidy1$|^mehidy2$|^mehidy3$|^mehidy4$|^mehidy5$/", $_POST["user"]) === 0)
$errUser = '<p class="errText">User must be bigger that 5 chars and contain only digits, letters and underscore</p>';
// Password must be strong
//if(preg_match("/^.*(?=.{8,})(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).*$/", $_POST["pass"]) === 0)
if(preg_match("/^.*(?=.{8,})(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).*$/", $_POST["pass"]) === 0)
$errPass = '<p class="errText">Password must be at least 8 characters and must contain at least one lower case letter, one upper case letter and one digit</p>';
}
?>
<body>
<center>
<form name="main" action="<?php $PHP_SELF ?>" method="POST">
<input type="hidden" name="ac" value="login">
<table width="500" border="0" cellpadding="4" cellspacing="0" bordercolor="#000000" bgcolor="#EDEFF1">
<tr align="center">
<td colspan="2"><strong style="font-size:18px">Field Verification</strong><br>by <a href="http://www.mehidy.com" target="_blank">mehidy.com</a></td>
</tr>
<tr align="center" bgcolor="#FD9003">
<td colspan="2" bgcolor="#A6B39D">Registration Form</td>
</tr>
<tr>
<td>Full Name:</td>
<td>
<input name="name" type="text" size="50" maxlength="100" value="<?php echo $_POST["name"]; ?>">
<?php if(isset($errName)) echo $errName; ?>
</td>
</tr>
<tr>
<td>Address:</td>
<td>
<input name="address" type="text" size="50" maxlength="250" value="<?php echo $_POST["address"]; ?>">
<?php if(isset($errAddress)) echo $errAddress; ?>
</td>
</tr>
<tr>
<td>Email:</td>
<td>
<input name="email" type="text" size="50" value="<?php echo $_POST["email"]; ?>">
<?php if(isset($errEmail)) echo $errEmail; ?>
</td>
</tr>
<tr>
<td>Passport:</td>
<td>
<input name="passport" type="text" size="16" maxlength="12" value="<?php echo $_POST["passport"]; ?>">
<?php if(isset($errPassport)) echo $errPassport; ?>
</td>
</tr>
<tr>
<td>Phone:</td>
<td>
<input name="phone" type="text" size="16" value="<?php echo $_POST["phone"]; ?>">
<?php if(isset($errPhone)) echo $errPhone; ?>
</td>
</tr>
<tr>
<td>Zip code:</td>
<td>
<input name="zip" type="text" size="16" value="<?php echo $_POST["zip"]; ?>">
<?php if(isset($errZip)) echo $errZip; ?>
</td>
</tr>
<tr>
<td>Date:</td>
<td>
<input name="date" type="text" size="16" value="<?php echo $_POST["date"]; ?>">
<?php if(isset($errDate)) echo $errDate; ?>
</td>
</tr>
<tr>
<td>Username:</td>
<td>
<input name="user" type="text" size="16" value="<?php echo $_POST["user"]; ?>">
<?php if(isset($errUser)) echo $errUser; ?>
</td>
</tr>
<tr>
<td>Password:</td>
<td>
<input name="pass" type="password" size="16" value="<?php echo $_POST["pass"]; ?>">
<?php if(isset($errPass)) echo $errPass; ?>
</td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>
</center>
</body>
</html>