I have the following code.
<?
include 'db.php';
// Define post fields into simple variables
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$kids_name = $_POST['kids_name'];
$email_address = $_POST['email_address'];
$username = $_POST['username'];
$password=$_POST['password'];
$info = $_POST['info'];
$grade = intval($_POST['grade']);
/* Lets strip some slashes in case the user entered
any escaped characters. */
$first_name = addslashes($first_name);
$last_name = addslashes($last_name);
$kids_name = addslashes($kids_name);
$email_address = addslashes($email_address);
$username = addslashes($username);
$password = addslashes($password);
$info = addslashes($info);
/* Do some error checking on the form posted fields */
if((!$first_name) || (!$last_name) || (!$email_address) || (!$username) || (!grade)){
echo 'You did not submit the following required information! <br />';
if(!$first_name){
echo "First Name is a required field. Please enter it below.<br />";
}
if(!$last_name){
echo "Last Name is a required field. Please enter it below.<br />";
}
if(!$kids_name){
echo "Kids Name is a required field. Please enter it below.<br />";
}
if(!$email_address){
echo "Email Address is a required field. Please enter it below.<br />";
}
if(!$password){
echo "Password is a required field. Please enter it below.<br />";
}
if(!$username){
echo "Desired Username is a required field. Please enter it below.<br />";
if(!$grade){
echo "Grade is a required field. Please enter it below.<br />";
}
include 'join_form.php'; // Show the form again!
/* End the error checking and if everything is ok, we'll move on to
creating the user account */
exit(); // if the error checking has failed, we'll exit the script!
}
/* Let's do some checking and ensure that the user's email address or username
does not exist in the database */
$sql_email_check = mysql_query("SELECT email_address FROM users WHERE email_address='$email_address'");
$sql_username_check = mysql_query("SELECT username FROM users WHERE username='$username'");
$email_check = mysql_num_rows($sql_email_check);
$username_check = mysql_num_rows($sql_username_check);
if(($email_check > 0) || ($username_check > 0)){
echo "Please fix the following errors: <br />";
if($email_check > 0){
echo "<strong>Your email address has already been registered by another member in our database. Please submit a different Email address!<br />";
unset($email_address);
}
if($username_check > 0){
echo "The username you have selected has already been registered by another member in our database. Please choose a different Username!<br />";
unset($username);
}
include 'join_form.php'; // Show the form again!
exit(); // exit the script so that we do not create this account!
}
/* Everything has passed both error checks that we have done.
It's time to create the account! */
//lets say where the files are going and the directory name
$newDir = ($kids_name);
$path = ("public_html/scn/$grade");
//Lets encrypt the password
$db_password = md5($password);
//Before we enter it all into the database lets first create the folder
// create directory through FTP connection
function FtpMkdir($path, $newDir) {
$server='***'; // ftp server
$connection = ftp_connect($server); // connection
// login to ftp server
$user = '***";
$pass = "***";
$result = ftp_login($connection, $user, $pass);
// check if connection was made
if ((!$connection) || (!$result)) {
return false;
exit();
} else {
ftp_chdir($connection, $path); // go to destination dir
if(ftp_mkdir($connection,$newDir)) { // create directory
return $newDir;
} else {
return false;
}
ftp_close($conn_id); // close connection
}
}
// Enter info into the Database.
$info2 = htmlspecialchars($info);
$sql = mysql_query("INSERT INTO users (first_name, last_name, kids_name, email_address, username, password, info, signup_date, decrypted_password)
VALUES('$first_name', '$last_name', '$kids_name', '$email_address', '$username', '$db_password', '$info2', now(), '$password')") or die (mysql_error());
if(!$sql){
echo 'There has been an error creating your account. Please contact the webmaster.';
} else {
$userid = mysql_insert_id();
$activatepath = "activate.php?id=$userid&code=$db_password";
// Let's mail the user!
$subject = "Membership request at $sitename";
$message = "Dear $first_name $last_name,
You are now registered at our website, $sitepath !
To activate your membership, please login here: $sitepath$activatepath
Once you activate your membership, you will be able to login with the following information:
Username: $username
Password: $password
Please keep this username and password in a location that is easily accessible by you.
FOR RIGHT NOW DO NOT CLICK THE AVTIVATE LINK UNTIL I GET IT FIXED
Thanks!
Webmaster, $sitename
This is an automated response, please do not reply!";
mail($email_address, $subject, $message, "From: $sitename <$adminemail>\nX-Mailer: PHP/" . phpversion());
echo 'Your membership information has been mailed to your email address! Please check it and follow the directions!,<br> FOR RIGHT NOW DO NOT CLICK THE AVTIVATE LINK UNTIL I GET IT FIXED';
}
//here is line 155. which makes me think of } is missing
?>
When i run it it says parse error unexpected $ on line 155.
also using that code how can i create a php file using that. I need it to be dynamic so i would like to include it in that file.
Thanks for your time and help