Here im working on this code and I cat quite get it to work I want it to take the entries from a form, check to see that they meet the criteria (pass must be 6 chars, must be 13 or older) and then insert them into a table in a database.
here is the php i have
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
//Connnect to database as root user
$con = mysql_connect("localhost","root","admin");
//select database members
mysql_select_db("members", $con);
//set variables for form entries
$firstname = $_POST['first'];
$lastname = $_POST['last'];
$age = $_POST['age'];
$email = $_POST['email'];
//set password variable and set its length
$password = $_POST['password'];
$length = strlen($password);
if ($length>=6 && $age>=13)
{
$sql = "INSERT INTO users
(firstname, lastname, age, email, password)
VALUES
('$firstname', '$lastname', '$age', '$email', '$password')";
}
//conditionals for password criteria
if (mysql_query($sql,$con) && $length >= 6 && $age <= 13)
{
echo "Thank You For Registering";
}
else
{
echo "<font face='Verdana' size='2' color=red>Click here to proceed to login.<br><center>
<input type='button' value='Proceed' onClick='http://localhost/login.html'></center>";
}
?>
</body>
</html>
and the form is
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style>
<!--
body {
background-color : #CCC888;
font-family : arial, times, sans-serif;
}
table {
border : 1px solid #000;
background-color : #2011A2;
}
td.blue {
color : #ffffff;
}
td.white {
background-color : #ffffff;
}
-->
</style>
</head>
<body>
<table>
<form method="POST" action="register.php">
<tr><td class="blue">First name:</td>
<td class="white"><input type="text" name="first"></td></tr>
<tr><td class="white">Last name:</td>
<td><input type="text" name="last"></td></tr>
<tr><td class="blue">Age:</td>
<td class="white"><input type="text" name="age"></td></tr>
<tr><td class="white">Email:</td>
<td><input type="text" name="email"></td></tr>
<tr><td class="blue">Password:</td>
<td class="white"><input type="password" name="password"></td></tr>
<tr><td>
<input type="submit" value="Register"><td>
</tr>
</form>
</table>
</body>
</html>