Current location: Hot Scripts Forums » Programming Languages » PHP » Frustrated out of my mind! Pretty Pretty Please HelP!


Frustrated out of my mind! Pretty Pretty Please HelP!

Reply
  #1 (permalink)  
Old 11-10-08, 09:20 PM
jdlev jdlev is offline
Newbie Coder
 
Join Date: Nov 2008
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Hazard 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>
Reply With Quote
  #2 (permalink)  
Old 11-10-08, 09:23 PM
jdlev jdlev is offline
Newbie Coder
 
Join Date: Nov 2008
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Here is the 2nd file that the "include" function is supposed to pull in at the top of the first document.

PHP Code:

<html>

<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<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>
Reply With Quote
  #3 (permalink)  
Old 11-11-08, 07:12 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
Quote:
Originally Posted by jdlev View Post
Here is the 2nd file that the "include" function is supposed to pull in at the top of the first document.

PHP Code:

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<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");
   }
?>
__________________
Jerry Broughton

Last edited by job0107; 11-11-08 at 07:28 AM.
Reply With Quote
  #4 (permalink)  
Old 11-11-08, 02:53 PM
jdlev jdlev is offline
Newbie Coder
 
Join Date: Nov 2008
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
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?

Thanks again for your help!
Reply With Quote
  #5 (permalink)  
Old 11-11-08, 03:30 PM
smithygotlost smithygotlost is offline
Aspiring Coder
 
Join Date: Jul 2006
Location: United Kingdom
Posts: 413
Thanks: 12
Thanked 3 Times in 3 Posts
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>
let me know if it works

thanks
mike
Reply With Quote
  #6 (permalink)  
Old 11-11-08, 03:47 PM
jdlev jdlev is offline
Newbie Coder
 
Join Date: Nov 2008
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
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
Reply With Quote
  #7 (permalink)  
Old 11-11-08, 04:15 PM
smithygotlost smithygotlost is offline
Aspiring Coder
 
Join Date: Jul 2006
Location: United Kingdom
Posts: 413
Thanks: 12
Thanked 3 Times in 3 Posts
thats good well sort of

its this line thats the problem

PHP Code:

$myquery "INSERT INTO users (firstName, lastName, username, password, " $myquery .= "status) VALUES ('$firstName', '$lastName', '$username', " $myquery .= "'$password', '$status')"
i think this should work

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, 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>
let me know

thanks
mike
Reply With Quote
  #8 (permalink)  
Old 11-11-08, 04:34 PM
jdlev jdlev is offline
Newbie Coder
 
Join Date: Nov 2008
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Just tried it

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
Reply With Quote
  #9 (permalink)  
Old 11-11-08, 04:39 PM
smithygotlost smithygotlost is offline
Aspiring Coder
 
Join Date: Jul 2006
Location: United Kingdom
Posts: 413
Thanks: 12
Thanked 3 Times in 3 Posts
ok ive //'ed some of your code out try 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, 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>
thanks
mike
Reply With Quote
  #10 (permalink)  
Old 11-11-08, 04:41 PM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
PHP Code:

$error verify_data(SHTTP_POST_VARS); 

... this is probably supposed to be $HTTP_POST_VARS.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help! I am going out of my mind! Sationus Job Offers & Assistance 7 10-01-05 03:02 AM


All times are GMT -5. The time now is 08:24 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.