Frustrated out of my mind! Pretty Pretty Please HelP!
Parse error: syntax error, unexpected '{' in C:\Inetpub\wwwroot\TAS\admin\TMPdd72na5ods.php on line 69
PHP Parse error: syntax error, unexpected '{' in C:\Inetpub\wwwroot\TAS\admin\TMPdd72na5ods.php on line 69
There is no damn '{' on line 69 of the php file.
I have tried everything to get this to work, and can't get it to budge. The only thing that is funny that happens is the location of the problem will jump from one line to another.
Here is my code...anyone fixes this problem for me, and I will nominate you for sainthood.
PHP Code:
<?php include("/include/tas_client_admin.php"); ?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p><strong><font size="4" face="Georgia, Times New Roman, Times, serif">Telephone Answering Service.com Administration Console</font></strong></p>
<p><em><strong>Note: Unauthorized use is strictly prohibited. Any unauthorized
use will be prosecuted to the full extent of the law.</strong></em></p>
<form action="<?php echo($PHP_SELF) ?>" method="post" name="createuser">
<table width="50%" border="1" align="center">
<tr>
<td width="51%"><div align="right">First Name:</div></td>
<td width="49%"><input name="firstName" type="text" id="firstName" maxlength="20"></td>
</tr>
<tr>
<td><div align="right">Last Name:</div></td>
<td><input name="lastName" type="text" id="lastName" maxlength="30"></td>
</tr>
<tr>
<td><div align="right">Company:</div></td>
<td><input name="company" type="text" id="company" maxlength="20"></td>
</tr>
<tr>
<td><div align="right">Username:</div></td>
<td><input name="userNAME" type="text" id="userNAME" maxlength="20"></td>
</tr>
<tr>
<td><div align="right">Password:</div></td>
<td><input name="password" type="text" id="password" maxlength="20"></td>
</tr>
<tr>
<td><div align="right">Confirm Password:</div></td>
<td><input name="confirmpassword" type="text" id="confirmpassword" maxlength="20"></td>
</tr>
<tr>
<td><div align="right">User Status:</div></td>
<td><select name="status" size="1">
<option value="Staff" selected>Staff</option>
<option value="Admin">Admin</option>
</select></td>
</tr>
<tr>
<td><div align="left"></div></td>
<td><input name="Submit" type="submit" id="Submit" value="Create User"></td>
</tr>
</table>
</form>
<?php
function insert_data($formdata)
// Insert Data into the users table
// $formdata = Form data array
// set up database connection
{
$error = "";
$myhost = "localhost";
$myuser = "root";
$mypass = "password";
$mydb = "db";
// set up data to insert
$firstName = $formdata['firstName'];
$lastName = $formdata['lastName'];
$username = $formdata['username'];
$password = $formdata['password'];
$status = $formdata['status'];
//encrypt the password using key
$password = crypt{$password, "123TAS");
//connect to mySQL server
$mysql = mysql_connect($myhost, $myuser, $mypass);
if (!$mysql)
{
$error - "Cannot connect to mySQL server";
return($error);
}
//connect to database
$mysqldb = mysql_select_db($mydb, $mysql);
if (!$mysqldb)
{
$error = "Cannot open database";
return($error);
}
//Insert Data
$myquery = "INSERT INTO users (firstName, lastName, username, password, "
$myquery .= "status) VALUES ('$firstName', '$lastName', '$username', "
$myquery .= "'$password', '$status')";
$result = mysql_query($myquery, $mysql);
if (!$result)
{
$error = "Cannot Run Query";
return ($error);
}
//Return True if record written successfully
return("true");
}
?>
<?php
function veryify_data($formdata)
{
// This function uses the functions in the include file,
// and uses them to validate various aspects of the form
// If validation fails, it returns $error, the appropriate error message
// If validation succeeds, return true
$error = "";
$form_data = trim_data($formdata);
$user = $form_data['username'];
// check all form fields are filled in
if (!check_form($form_data))
{
$error="All Form Fields Must Be Filled In";
return($error);
}
// check password and confirmation password match
if (!confirm_password($form_data, "password", "confirmpassword"))
{
$error = "The passwords do not match, please reenter your passwords";
return($error)
}
// check length of password
if (!check_password_length($form_data, 'password', 5))
{
$error = "Password should be 5 characters or more";
return($error)
}
// check that the username is unique
$check = check_unique($user, 'php', 'localhost', 'php', '20012001', 'users', 'username');
if ($check != "true")
{
$error = "Username is already in use, please select another";
Return($error);
}
// if validated successfully, insert data into table
$insert_check = insert_data($formdata);
// if error with insertion, return error
if ($insert_check != "true")
return($insert_check);
// form validated and record inserted automatically
return("");
}
?>
<?php
// Main Code - Verifies the form data, and inserts into
// the users table in the database.
if($Submit=="Create User")
{
$error = verify_data(SHTTP_POST_VARS);
if ($error == "")
$success = "User inserted successfully";
}
?> <?php echo($error); ?>
<?php echo($success); ?>
</body>
</html>
<body>
<?php
function trim_data($formdata)
{
//Trim any leading or trailing spaces
// $formdata = Form data array
foreach($formdata as $key => $value)
{
$key = trim($key) ;
$value = trim($value) ;
}
return $formdata;
}
function check_form($formdata)
{
// Check all fields are filled in
// $formdata = Form data array
foreach ($formdata as $key => $value)
{
if (!isset($key) || $value == "")
return false;
}
return true;
}
function check_password_length($formdata, $password, $minlen)
{
// Check that password is required length
// $formdata = Form data array
// $password = Name of password field
// $minlen = Minimum number of password characters
if (strlen($formdata[$password]) < $minlen
return false;
else
return true;
}
function confirm_password($formdata, $password1, $password2)
{
// Check that two passwords given match
// $formdata = Form data array
// $password1 = name of first password field
// $password2 = name of second password field
if ($formdata[$password1] === $formdata[$password2])
return true;
else
return false;
}
function check_unique($formvalue, $db, $dbhost, $dbuser, $dbpassword, $table, $field)
{
// Checks a table in a database, to see if passed value already exists
// $formvalue = Value you are checking to see whether it is unique
// $db = mySQL Database Name
// $dbhost = mySQL Server address, for example localhost
// $dbuser = mySQL user name
// $dbpassword = mySQL password
// $table = mySQL table to search
// $field = mySQL field to search
$error = "";
// Connect to the mySQL server
$mySQL = mysql_connect($dbhost, $dbuser, $dbpassword);
if(!$mysql)
{$error = "Cannont connect to Database Host";
return($error);
}
//Query Table to see if $formvalue is unique
$myquery = "SELECT * FROM $table WHERE $field = '$formvalue'";
$result = mysql_query($myquery);
if (!$result)
{
$error = "Cannot run query";
return($error);
}
// Get number of Records found, should be 0 if $formvalue is unique
$unique = mysql_num_rows($result);
if ($unique > 0)
{
$error = $formvalue. " already in use";
return($error);
}
// Return true if $formvalue is unique
return ("true");
}
?>
</body>
</html>
<body> <?php function trim_data($formdata) { //Trim any leading or trailing spaces // $formdata = Form data array foreach($formdata as $key => $value) { $key = trim($key) ; $value = trim($value) ; } return $formdata; }
function check_form($formdata) { // Check all fields are filled in // $formdata = Form data array foreach ($formdata as $key => $value) { if (!isset($key) || $value == "") return false; } return true; }
function check_password_length($formdata, $password, $minlen) { // Check that password is required length // $formdata = Form data array // $password = Name of password field // $minlen = Minimum number of password characters if (strlen($formdata[$password]) < $minlen return false; else return true; }
function confirm_password($formdata, $password1, $password2) { // Check that two passwords given match // $formdata = Form data array // $password1 = name of first password field // $password2 = name of second password field
if ($formdata[$password1] === $formdata[$password2]) return true; else return false; }
function check_unique($formvalue, $db, $dbhost, $dbuser, $dbpassword, $table, $field) { // Checks a table in a database, to see if passed value already exists // $formvalue = Value you are checking to see whether it is unique // $db = mySQL Database Name // $dbhost = mySQL Server address, for example localhost // $dbuser = mySQL user name // $dbpassword = mySQL password // $table = mySQL table to search // $field = mySQL field to search $error = "";
// Connect to the mySQL server $mySQL = mysql_connect($dbhost, $dbuser, $dbpassword); if(!$mysql) {$error = "Cannont connect to Database Host"; return($error); }
//Query Table to see if $formvalue is unique $myquery = "SELECT * FROM $table WHERE $field = '$formvalue'"; $result = mysql_query($myquery); if (!$result) { $error = "Cannot run query"; return($error); }
// Get number of Records found, should be 0 if $formvalue is unique $unique = mysql_num_rows($result); if ($unique > 0) { $error = $formvalue. " already in use"; return($error); }
// Return true if $formvalue is unique return ("true"); } ?> </body> </html>
In the above code, look at this function:
PHP Code:
function check_password_length($formdata, $password, $minlen) { // Check that password is required length // $formdata = Form data array // $password = Name of password field // $minlen = Minimum number of password characters if (strlen($formdata[$password]) < $minlen return false; else return true; }
It should be like this:
PHP Code:
function check_password_length($formdata, $password, $minlen) { // Check that password is required length // $formdata = Form data array // $password = Name of password field // $minlen = Minimum number of password characters if (strlen($formdata[$password]) < $minlen) return false; else return true; }
Or this:
PHP Code:
function check_password_length($formdata, $password, $minlen) { // Check that password is required length // $formdata = Form data array // $password = Name of password field // $minlen = Minimum number of password characters if (strlen($formdata[$password]) < $minlen) {return false;} else {return true;} }
Either way will work.
Also one other thing to consider,
this file is a collection of PHP functions,
and with the inclusion of the HTML tags (<html><head></head><body></body></html>),
have the potential of interfering with the HTML tags in the page it is being included in.
You would be wise to write it like this:
tas_client_admin.php
PHP Code:
<?php function trim_data($formdata) { //Trim any leading or trailing spaces // $formdata = Form data array foreach($formdata as $key => $value) { $key = trim($key) ; $value = trim($value) ; } return $formdata; }
function check_form($formdata) { // Check all fields are filled in // $formdata = Form data array foreach ($formdata as $key => $value) { if (!isset($key) || $value == "") return false; } return true; }
function check_password_length($formdata, $password, $minlen) { // Check that password is required length // $formdata = Form data array // $password = Name of password field // $minlen = Minimum number of password characters if (strlen($formdata[$password]) < $minlen) return false; else return true; }
function confirm_password($formdata, $password1, $password2) { // Check that two passwords given match // $formdata = Form data array // $password1 = name of first password field // $password2 = name of second password field
if ($formdata[$password1] === $formdata[$password2]) return true; else return false; }
function check_unique($formvalue, $db, $dbhost, $dbuser, $dbpassword, $table, $field) { // Checks a table in a database, to see if passed value already exists // $formvalue = Value you are checking to see whether it is unique // $db = mySQL Database Name // $dbhost = mySQL Server address, for example localhost // $dbuser = mySQL user name // $dbpassword = mySQL password // $table = mySQL table to search // $field = mySQL field to search $error = "";
// Connect to the mySQL server $mySQL = mysql_connect($dbhost, $dbuser, $dbpassword); if(!$mysql) {$error = "Cannont connect to Database Host"; return($error); }
//Query Table to see if $formvalue is unique $myquery = "SELECT * FROM $table WHERE $field = '$formvalue'"; $result = mysql_query($myquery); if (!$result) { $error = "Cannot run query"; return($error); }
// Get number of Records found, should be 0 if $formvalue is unique $unique = mysql_num_rows($result); if ($unique > 0) { $error = $formvalue. " already in use"; return($error); }
// Return true if $formvalue is unique return ("true"); } ?>
Hi Jerry. Thanks for your help so far, I really appreciate it. It still doesn't seem to be working, and I am not sure why? Whenever I run the "functions" or "tas_client_admin.php" page, they seem to run ok by themselves and don't throw off any errors. When I try to run the main page "create_users.php", it throws off the following error:
Parse error: syntax error, unexpected '{' in C:\Inetpub\wwwroot\TAS\admin\TMP1pk3ia716a.php on line 69
PHP Parse error: syntax error, unexpected '{' in C:\Inetpub\wwwroot\TAS\admin\TMP1pk3ia716a.php on line 69
I changed the information in my "tas_client_admin.php" page and copied in your corrected version, and it didn't work. I tried to even link it to the page that you rewrote and recommended.
I have no idea why this still won't work.
I am working with dreamweaver mx/IIS 5.0 on windows advanced server 2000/mysql 5/php 5?
see you guys have all checked everything but one thing your page said an error on page 69 wasnt quiet on the money look here
PHP Code:
$password = crypt{$password, "123TAS");
the problem is here crypt{$password
shouldnt that be an ) ??? so what if you change that it looks like this
PHP Code:
<?php include("/include/tas_client_admin.php"); ?> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <p><strong><font size="4" face="Georgia, Times New Roman, Times, serif">Telephone Answering Service.com Administration Console</font></strong></p> <p><em><strong>Note: Unauthorized use is strictly prohibited. Any unauthorized use will be prosecuted to the full extent of the law.</strong></em></p> <form action="<?php echo($PHP_SELF) ?>" method="post" name="createuser"> <table width="50%" border="1" align="center"> <tr> <td width="51%"><div align="right">First Name:</div></td> <td width="49%"><input name="firstName" type="text" id="firstName" maxlength="20"></td> </tr> <tr> <td><div align="right">Last Name:</div></td> <td><input name="lastName" type="text" id="lastName" maxlength="30"></td> </tr> <tr> <td><div align="right">Company:</div></td> <td><input name="company" type="text" id="company" maxlength="20"></td> </tr> <tr> <td><div align="right">Username:</div></td> <td><input name="userNAME" type="text" id="userNAME" maxlength="20"></td> </tr> <tr> <td><div align="right">Password:</div></td> <td><input name="password" type="text" id="password" maxlength="20"></td> </tr> <tr> <td><div align="right">Confirm Password:</div></td> <td><input name="confirmpassword" type="text" id="confirmpassword" maxlength="20"></td> </tr> <tr> <td><div align="right">User Status:</div></td> <td><select name="status" size="1"> <option value="Staff" selected>Staff</option> <option value="Admin">Admin</option> </select></td> </tr> <tr> <td><div align="left"></div></td> <td><input name="Submit" type="submit" id="Submit" value="Create User"></td> </tr> </table> </form> <?php function insert_data($formdata) // Insert Data into the users table // $formdata = Form data array // set up database connection { $error = ""; $myhost = "localhost"; $myuser = "root"; $mypass = "password"; $mydb = "db"; // set up data to insert $firstName = $formdata['firstName']; $lastName = $formdata['lastName']; $username = $formdata['username']; $password = $formdata['password']; $status = $formdata['status']; //encrypt the password using key $password = crypt($password, "123TAS");
//connect to mySQL server $mysql = mysql_connect($myhost, $myuser, $mypass); if (!$mysql) { $error - "Cannot connect to mySQL server"; return($error); } //connect to database $mysqldb = mysql_select_db($mydb, $mysql); if (!$mysqldb) { $error = "Cannot open database"; return($error); } //Insert Data $myquery = "INSERT INTO users (firstName, lastName, username, password, " $myquery .= "status) VALUES ('$firstName', '$lastName', '$username', " $myquery .= "'$password', '$status')"; $result = mysql_query($myquery, $mysql); if (!$result) { $error = "Cannot Run Query"; return ($error); } //Return True if record written successfully return("true"); } ?> <?php function veryify_data($formdata) { // This function uses the functions in the include file, // and uses them to validate various aspects of the form // If validation fails, it returns $error, the appropriate error message // If validation succeeds, return true $error = ""; $form_data = trim_data($formdata); $user = $form_data['username']; // check all form fields are filled in if (!check_form($form_data)) { $error="All Form Fields Must Be Filled In"; return($error); } // check password and confirmation password match if (!confirm_password($form_data, "password", "confirmpassword")) { $error = "The passwords do not match, please reenter your passwords"; return($error) } // check length of password if (!check_password_length($form_data, 'password', 5)) { $error = "Password should be 5 characters or more"; return($error) } // check that the username is unique $check = check_unique($user, 'php', 'localhost', 'php', '20012001', 'users', 'username'); if ($check != "true") { $error = "Username is already in use, please select another"; Return($error); } // if validated successfully, insert data into table $insert_check = insert_data($formdata);
// if error with insertion, return error if ($insert_check != "true") return($insert_check);
// form validated and record inserted automatically return(""); } ?>
<?php // Main Code - Verifies the form data, and inserts into // the users table in the database. if($Submit=="Create User") { $error = verify_data(SHTTP_POST_VARS); if ($error == "") $success = "User inserted successfully"; } ?> <?php echo($error); ?> <?php echo($success); ?> </body> </html>
Hey mike, just gave it a shot...don't get the error on 69 anymore or the same error code, but it still doesn't work. You've got great eyes! I'm surprised you caught that with the crypt function!
Anyways...here's what its saying now:
Parse error: syntax error, unexpected T_VARIABLE in C:\Inetpub\wwwroot\TAS\admin\TMP3qfp6a73sq.php on line 88
PHP Parse error: syntax error, unexpected T_VARIABLE in C:\Inetpub\wwwroot\TAS\admin\TMP3qfp6a73sq.php on line 88
<?php include("/include/tas_client_admin.php"); ?> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <p><strong><font size="4" face="Georgia, Times New Roman, Times, serif">Telephone Answering Service.com Administration Console</font></strong></p> <p><em><strong>Note: Unauthorized use is strictly prohibited. Any unauthorized use will be prosecuted to the full extent of the law.</strong></em></p> <form action="<?php echo($PHP_SELF) ?>" method="post" name="createuser"> <table width="50%" border="1" align="center"> <tr> <td width="51%"><div align="right">First Name:</div></td> <td width="49%"><input name="firstName" type="text" id="firstName" maxlength="20"></td> </tr> <tr> <td><div align="right">Last Name:</div></td> <td><input name="lastName" type="text" id="lastName" maxlength="30"></td> </tr> <tr> <td><div align="right">Company:</div></td> <td><input name="company" type="text" id="company" maxlength="20"></td> </tr> <tr> <td><div align="right">Username:</div></td> <td><input name="userNAME" type="text" id="userNAME" maxlength="20"></td> </tr> <tr> <td><div align="right">Password:</div></td> <td><input name="password" type="text" id="password" maxlength="20"></td> </tr> <tr> <td><div align="right">Confirm Password:</div></td> <td><input name="confirmpassword" type="text" id="confirmpassword" maxlength="20"></td> </tr> <tr> <td><div align="right">User Status:</div></td> <td><select name="status" size="1"> <option value="Staff" selected>Staff</option> <option value="Admin">Admin</option> </select></td> </tr> <tr> <td><div align="left"></div></td> <td><input name="Submit" type="submit" id="Submit" value="Create User"></td> </tr> </table> </form> <?php function insert_data($formdata) // Insert Data into the users table // $formdata = Form data array // set up database connection { $error = ""; $myhost = "localhost"; $myuser = "root"; $mypass = "password"; $mydb = "db"; // set up data to insert $firstName = $formdata['firstName']; $lastName = $formdata['lastName']; $username = $formdata['username']; $password = $formdata['password']; $status = $formdata['status']; //encrypt the password using key $password = crypt($password, "123TAS");
//connect to mySQL server $mysql = mysql_connect($myhost, $myuser, $mypass); if (!$mysql) { $error - "Cannot connect to mySQL server"; return($error); } //connect to database $mysqldb = mysql_select_db($mydb, $mysql); if (!$mysqldb) { $error = "Cannot open database"; return($error); } //Insert Data $myquery = "INSERT INTO users (firstName, lastName, username, password, status) VALUES ('$firstName', '$lastName', '$username', '$password', '$status')"; $result = mysql_query($myquery, $mysql); if (!$result) { $error = "Cannot Run Query"; return ($error); } //Return True if record written successfully return("true"); } ?> <?php function veryify_data($formdata) { // This function uses the functions in the include file, // and uses them to validate various aspects of the form // If validation fails, it returns $error, the appropriate error message // If validation succeeds, return true $error = ""; $form_data = trim_data($formdata); $user = $form_data['username']; // check all form fields are filled in if (!check_form($form_data)) { $error="All Form Fields Must Be Filled In"; return($error); } // check password and confirmation password match if (!confirm_password($form_data, "password", "confirmpassword")) { $error = "The passwords do not match, please reenter your passwords"; return($error) } // check length of password if (!check_password_length($form_data, 'password', 5)) { $error = "Password should be 5 characters or more"; return($error) } // check that the username is unique $check = check_unique($user, 'php', 'localhost', 'php', '20012001', 'users', 'username'); if ($check != "true") { $error = "Username is already in use, please select another"; Return($error); } // if validated successfully, insert data into table $insert_check = insert_data($formdata);
// if error with insertion, return error if ($insert_check != "true") return($insert_check);
// form validated and record inserted automatically return(""); } ?>
<?php // Main Code - Verifies the form data, and inserts into // the users table in the database. if($Submit=="Create User") { $error = verify_data(SHTTP_POST_VARS); if ($error == "") $success = "User inserted successfully"; } ?> <?php echo($error); ?> <?php echo($success); ?> </body> </html>
Parse error: syntax error, unexpected '}' in C:\Inetpub\wwwroot\TAS\admin\TMPcyhua75ym.php on line 118
PHP Parse error: syntax error, unexpected '}' in C:\Inetpub\wwwroot\TAS\admin\TMPcyhua75ym.php on line 118
<?php include("/include/tas_client_admin.php"); ?> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <p><strong><font size="4" face="Georgia, Times New Roman, Times, serif">Telephone Answering Service.com Administration Console</font></strong></p> <p><em><strong>Note: Unauthorized use is strictly prohibited. Any unauthorized use will be prosecuted to the full extent of the law.</strong></em></p> <form action="<?php echo($PHP_SELF) ?>" method="post" name="createuser"> <table width="50%" border="1" align="center"> <tr> <td width="51%"><div align="right">First Name:</div></td> <td width="49%"><input name="firstName" type="text" id="firstName" maxlength="20"></td> </tr> <tr> <td><div align="right">Last Name:</div></td> <td><input name="lastName" type="text" id="lastName" maxlength="30"></td> </tr> <tr> <td><div align="right">Company:</div></td> <td><input name="company" type="text" id="company" maxlength="20"></td> </tr> <tr> <td><div align="right">Username:</div></td> <td><input name="userNAME" type="text" id="userNAME" maxlength="20"></td> </tr> <tr> <td><div align="right">Password:</div></td> <td><input name="password" type="text" id="password" maxlength="20"></td> </tr> <tr> <td><div align="right">Confirm Password:</div></td> <td><input name="confirmpassword" type="text" id="confirmpassword" maxlength="20"></td> </tr> <tr> <td><div align="right">User Status:</div></td> <td><select name="status" size="1"> <option value="Staff" selected>Staff</option> <option value="Admin">Admin</option> </select></td> </tr> <tr> <td><div align="left"></div></td> <td><input name="Submit" type="submit" id="Submit" value="Create User"></td> </tr> </table> </form> <?php function insert_data($formdata) // Insert Data into the users table // $formdata = Form data array // set up database connection { $error = ""; $myhost = "localhost"; $myuser = "root"; $mypass = "password"; $mydb = "db"; // set up data to insert $firstName = $formdata['firstName']; $lastName = $formdata['lastName']; $username = $formdata['username']; $password = $formdata['password']; $status = $formdata['status']; //encrypt the password using key $password = crypt($password, "123TAS");
//connect to mySQL server $mysql = mysql_connect($myhost, $myuser, $mypass); if (!$mysql) { $error - "Cannot connect to mySQL server"; return($error); } //connect to database $mysqldb = mysql_select_db($mydb, $mysql); if (!$mysqldb) { $error = "Cannot open database"; return($error); } //Insert Data $myquery = "INSERT INTO users (firstName, lastName, username, password, status) VALUES ('$firstName', '$lastName', '$username', '$password', '$status')"; $result = mysql_query($myquery, $mysql); if (!$result) { $error = "Cannot Run Query"; return ($error); } //Return True if record written successfully return("true"); } ?> <?php function veryify_data($formdata) { // This function uses the functions in the include file, // and uses them to validate various aspects of the form // If validation fails, it returns $error, the appropriate error message // If validation succeeds, return true $error = ""; $form_data = trim_data($formdata); $user = $form_data['username']; // check all form fields are filled in if (!check_form($form_data)) { $error="All Form Fields Must Be Filled In"; return($error); } // check password and confirmation password match if (!confirm_password($form_data, "password", "confirmpassword")) { $error = "The passwords do not match, please reenter your passwords"; return($error) } // check length of password // if (!check_password_length($form_data, 'password', 5)) // { // $error = "Password should be 5 characters or more"; // return($error) // } // check that the username is unique $check = check_unique($user, 'php', 'localhost', 'php', '20012001', 'users', 'username'); if ($check != "true") { $error = "Username is already in use, please select another"; Return($error); } // if validated successfully, insert data into table $insert_check = insert_data($formdata);
// if error with insertion, return error if ($insert_check != "true") return($insert_check);
// form validated and record inserted automatically return(""); } ?>
<?php // Main Code - Verifies the form data, and inserts into // the users table in the database. if($Submit=="Create User") { $error = verify_data(SHTTP_POST_VARS); if ($error == "") $success = "User inserted successfully"; } ?> <?php echo($error); ?> <?php echo($success); ?> </body> </html>