Jump to content

phpnewbieca

Members
  • Posts

    71
  • Joined

  • Last visited

Everything posted by phpnewbieca

  1. Quote post #4 in this thread has nothing to do with your problem. it's probably just a spammer testing if the account he created works I agree It has nothing to do with my problem.
  2. Quote Hi. Maybe you can try utting the xml tag in the first line of your file. Please explain how the XML tag would help? Nothing I have read indicates the XML would be of use in this script. a. http://en.wikipedia.org/wiki/XML b. http://www.tizag.com/xmlTutorial/xmltag.php c. http://php.net/manual/en/language.basic-syntax.php
  3. Quote you missed $ in line $fh = fopen($MyfFile, "r"); Where? Line 33: $fh = fopen($MyFile, "r");
  4. Sleepy Member: I retyped the line. Newbie: I took the quotes off. and got this error: PHP Parse error: syntax error, unexpected T_STRING in on line 35 Line 35: if(strpos($olddata, "$searchfor")) { So, I took the quotes off: if(strpos($olddata, $searchfor)) { Then I received 'can't find it'. That is line 41: echo "can't find it"; The confirmation Number is in $MyFile: Confirmation Number: 905915307 Any Ideas why it cant find the confirmation number '905915307 '? <?php // Process valid_repair_upgradeform error_reporting(-1); //Define Variable(s) $date = date("D d M Y - H:i:s "); $my_file = "s_vcs.txt"; $my_path = $_SERVER['DOCUMENT_ROOT']."/home/users/web/b686/dom.horacela/public_html/"; $my_name = "Newbieca"; $my_mail = "coon-a@gmx.com"; $my_replyto = "coon-a@gmx.com"; $my_subject = "Order Validated"; $my_message = "This order was validated Confirmation Number: $confirmation_number on Date: $date.\r\n\r\n"; if (is_writable($my_file)) { echo " "; } else { echo 'The file is not writable\n\n'; } if (is_readable($my_file)) { echo " "; } else { echo 'The file is not readable'; } //Get Data From Form $confirmation_number = $_POST['confirmation_number']; // validate expected data exists if(!isset($_POST['confirmation_number'])) { echo "No Confirmation_number.\n"; die(); } // Search file for Confirmation_number. If found call function $MyFile = "s_vcs.txt"; $searchfor = $confirmation_number; $fh = fopen(MyfFile, "r"); $olddata = fread($fh, filesize($MyFile)); if(strpos($olddata, $searchfor)) { echo "fount it"; // Call Functions mail_attachment($my_file, $my_path, "horacfe@netscape.com", $my_mail, $my_name, $my_replyto, $my_subject, $my_message); } else { echo "can't find it"; } fclose($fh); //FUNCTION(S) function mail_attachment($filename, $path, $mailto, $from_mail, $from_name, $replyto, $subject, $message) { $file = $path.$filename; $file_size = filesize($file); $handle = fopen($file,"r"); $content = fread($handle,$file_size); fclose($handle); $content = chunk_split(base64_encode($content)); $uid = md5(uniqid(time())); $name = basename($file); $header = "From: ".$from_name." <".$from_mail.">\r\n"; $header .= "Reply-To: ".$replyto."\r\n"; $header .= "MIME-Version: 1.0\r\n"; $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n"; $header .= "This is a multi-part message in MIME format.\r\n"; $header .= "--".$uid."\r\n"; $header .= "Content-type:text/plain; charset=iso-8859-1\r\n"; $header .= "Content-Transfer-Encoding: 7bit\r\n\r\n"; $header .= $message."\r\n\r\n"; $header .= "--".$uid."\r\n"; $header .= "Content-Type: application/octet-stream; name=\"".$filename."\"\r\n"; // use different content types here $header .= "Content-Transfer-Encoding: base64\r\n"; $header .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n"; $header .= $content."\r\n\r\n"; $header .= "--".$uid."--"; if (mail($mailto, $subject, "", $header)) { echo "mail send ... OK"; // or use booleans here } else { echo "mail send ... ERROR!"; } } ?>
  5. I need some help. I received this error: PHP Parse error: syntax error, unexpected T_STRING in on line 33 Line 33: $fh = fopen("$MyFile", "r"); I read everything I could on this error but nothing applies to my situation. <?php // Process valid_repair_upgradeform error_reporting(-1); //Define Variable(s) $date = date("D d M Y - H:i:s "); $my_file = "s_vcs.txt"; $my_path = $_SERVER['DOCUMENT_ROOT']."/home/users/web/b686/dom.horacela/public_html/"; $my_name = "Newbieca"; $my_mail = "coon-a@gmx.com"; $my_replyto = "coon-a@gmx.com"; $my_subject = "Order Validated"; $my_message = "This order was validated Confirmation Number: $confirmation_number on Date: $date.\r\n\r\n"; if (is_writable($my_file)) { echo " "; } else { echo 'The file is not writable\n\n'; } if (is_readable($my_file)) { echo " "; } else { echo 'The file is not readable'; } //Get Data From Form $Confirmation_number = $_POST['Confirmation_number']; // validate expected data exists if(!isset($_POST['Confirmation_number'])) { echo "No Confirmation_number.\n"; die(); } // Search fille for Confirmation_number. If found call function $MyFile = "s_vcs.txt"; $searchfor = $Confirmation_number; $fh = fopen("$MyFile", "r"); $olddata = fread($fh, filesize($MyFile)); if(strpos($olddata, "$searchfor")) { echo "fount it"; // Call Functions mail_attachment($my_file, $my_path, "horacfe@netscape.com", $my_mail, $my_name, $my_replyto, $my_subject, $my_message); } else { echo "can't find it"; } fclose($fh); //FUNCTION(S) function mail_attachment($filename, $path, $mailto, $from_mail, $from_name, $replyto, $subject, $message) { $file = $path.$filename; $file_size = filesize($file); $handle = fopen($file,"r"); $content = fread($handle,$file_size); fclose($handle); $content = chunk_split(base64_encode($content)); $uid = md5(uniqid(time())); $name = basename($file); $header = "From: ".$from_name." <".$from_mail.">\r\n"; $header .= "Reply-To: ".$replyto."\r\n"; $header .= "MIME-Version: 1.0\r\n"; $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n"; $header .= "This is a multi-part message in MIME format.\r\n"; $header .= "--".$uid."\r\n"; $header .= "Content-type:text/plain; charset=iso-8859-1\r\n"; $header .= "Content-Transfer-Encoding: 7bit\r\n\r\n"; $header .= $message."\r\n\r\n"; $header .= "--".$uid."\r\n"; $header .= "Content-Type: application/octet-stream; name=\"".$filename."\"\r\n"; // use different content types here $header .= "Content-Transfer-Encoding: base64\r\n"; $header .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n"; $header .= $content."\r\n\r\n"; $header .= "--".$uid."--"; if (mail($mailto, $subject, "", $header)) { echo "mail send ... OK"; // or use booleans here } else { echo "mail send ... ERROR!"; } } ?>
  6. First, I would like to apologize to jcbones. The reason I could not understand your answer is I could not see the white space with Notepad++. After I downloaded, installed Geany editor and checked "Show white space" I understood your answer. Second, I would like to Thank mac_gyver for his response. Problem solved
  7. I agree "Unexpected ends are almost always missing closing braces }." I learned that after reading this article: http://en.kioskea.net/faq/3377-parse-error-syntax-error-unexpected-end I not quite sure I understand what you have written: Why? The closing line is Line now 271: ?> because I added a few lines of code but there is no white space before it or after it If you are referring to this line: $message= <<<EOF there is no white space before it or after it. I downloaded and installed Geany editor today. Please Please tell me how to detect code errors with it or where I can read how to detect missing brackets, white space, etc. with it. <?php // Process repair_upgradeform.html error_reporting(-1); // Create random number srand ((double) microtime() * 1000000); //Define Variable(s) $random_number = rand(); $confirmation_number = "$random_number"; $date = date("D d M Y - H:i:s "); $order_date = date("D d M Y"); $SendTo = "coon-a@gmx.com"; $From = "coon-a@gmx.com"; $error_message = ""; //Get Data From Form $Eighteen = $_POST['Eighteen']; $List = $_POST['List']; $Dsn = $_POST['Dsn']; $Title = $_POST['Title']; $Fname = $_POST['Fname']; $Lname = $_POST['Lname']; $Suffix = $_POST['Suffix']; $Address = $_POST['Address']; $CityState = $_POST['CityState']; $Zip = $_POST['Zip']; $Email = $_POST['Email']; $Phone = $_POST['Phone']; $Phone_2 = $_POST['Phone_2']; $TypeComputer = $_POST['TypeComputer']; $ComputerBrand = $_POST['ComputerBrand']; $ComputerModel = $_POST['ComputerModel']; if(isset($_POST['Cd'])) { $Cd = $_POST['Cd']; } if(isset($_POST['Cd_rw'])) { $Cd_rw = $_POST['Cd_rw']; } if(isset($_POST['Dvd'])) { $Dvd = $_POST['Dvd']; } if(isset($_POST['Dvd_rw'])) { $Dvd_rw = $_POST['Dvd_rw']; } if(isset($_POST['GraphicCard'])) { $GraphicCard = $_POST['GraphicCard']; } if(isset($_POST['Memory'])) { $Memory = $_POST['Memory']; } if(isset($_POST['Modem'])) { $Modem = $_POST['Modem']; } if(isset($_POST['Multimedia'])) { $Multimedia = $_POST['Multimedia']; } if(isset($_POST['NetworkCard'])) { $NetworkCard = $_POST['NetworkCard']; } if(isset($_POST['Software'])) { $SoundCard = $_POST['Software']; } if(isset($_POST['SoundCard'])) { $SoundCard = $_POST['SoundCard']; } if(isset($_POST['Speakers'])) { $Speakers = $_POST['Speakers']; } $Comments = $_POST['Comments']; //Define Variable $order_num = "$order_date-$LnameUc-$confirmation_number"; // validate expected data exists and is in the correct format ($Fname, $Lname, and $Email) if(!isset($_POST['Eighteen'])) { echo "No Age Verification.\n"; die(); } if(!isset($_POST['List'])) { echo "No Type Service.\n"; die(); } if(!isset($_POST['Dsn'])) { echo "No Date Service Needed.\n"; die(); } if(!isset($_POST['Fname'])) { echo "No First Name.\n"; died(); } if(!isset($_POST['Lname'])) { echo "No Last Name.\n"; died(); } if(!isset($_POST['CityState'])) { echo "No City\State.\n"; die(); } if(!isset($_POST['Email'])) { echo "No Email address.\n"; die(); } if (check_email_address($Email)) { echo $Email . " "; } else { echo $Email . " is not a valid email address.\n"; die(); } // Call Functions Repair_Upgrade_3(); //FUNCTIONS function died() { global $error_message; // your error code can go here echo "These errors appear below.\n"; echo "<br /><br />\n"; echo "$error_message\n"; echo "<br /><br />\n"; echo "Please go back and fix these errors.\n"; echo "<br /><br />\n"; die(); } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$Fname)) { $error_message.= 'The First Name you entered does not appear to be valid.<br />'; die(); } if(!preg_match($string_exp,$Lname)) { $error_message.= 'The Last Name you entered does not appear to be valid.<br />'; die(); } if(strlen($error_message) > 0) { die($error_message); } function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } function check_email_address($Email) { // First, we check that there's one @ symbol, and that the lengths are right if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $Email)) { // Email invalid because wrong number of characters in one section, or wrong number of @ symbols. echo "Email invalid because wrong number of characters in one section, or wrong number of @ symbols.\n"; echo "<br />\n"; return false; } // Split it into sections to make life easier $Email_array = explode("@", $Email); $local_array = explode(".", $Email_array[0]); for ($i = 0; $i < sizeof($local_array); $i++) { if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$",$local_array[$i])) { echo "Split it into sections to make life easier\n"; echo "<br />\n"; return false; } } if (!ereg("^\[?[0-9\.]+\]?$",$Email_array[1])) { // Check if domain is IP. If not, it should be valid domain name //echo "Check if domain is IP. If not, it should be valid domain name\n"; //echo "<br />\n"; $domain_array = explode(".", $Email_array[1]); if(sizeof($domain_array) < 2) { return false; // Not enough parts to domain echo "Not enough parts to domain\n"; echo "<br />\n"; } for ($i = 0; $i < sizeof($domain_array); $i++) { if(!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) { return false; } } } return true; } function Repair_Upgrade_3() { // Email Customer HTML global $date, $SendTo, $From, $error_message, $confirmation_number, $order_num, $Eighteen, $List, $Dsn, $Title, $Fname, $Lname, $Suffix, $Address, $CityState, $Zip, $Email, $Phone, $Phone_2, $TypeComputer, $ComputerBrand, $ComputerModel, $Cd, $Cd_rw, $Dvd, $Dvd_rw, $GraphicCard, $Memory, $Modem, $Multimedia, $NetworkCard, $Software, $SoundCard, $Speakers, $Comments; // Upper case First and last names $FnameUc = ucfirst($Fname); $LnameUc = ucfirst($Lname); //Create Array $List2=array(); if($Cd) { $List2[0]="CD<br>"; } if($Cd_rw) { $List2[1]="CD RW<br>"; } if($Dvd) { $List2[2]="DVD<br>"; } if($Dvd_rw) { $List2[3]="DVD RW<br>"; } if($GraphicCard) { $List2[4]="Graphic Card<br>"; } if($Memory) { $List2[5]="Memory<br>"; } if($Modem) { $List2[6]="Modem<br>"; } if($Multimedia) { $List2[7]="Multimedia<br>"; } if($NetworkCard) { $List2[8]="Network Card<br>"; } if($Software) { $List2[9]="Software<br>"; } if($SoundCard) { $List2[10]="Sound Card<br>"; } if($Speakers) { $List2[11]="Speakers<br><br>"; } $subject = "RE: Repair/Upgrade Order -- HTML\n\n"; //begin of HTML message $message = <<<EOF <html> <body BGCOLOR='tan' TEXT='black'><br> Hello $FnameUc<br> We received your request for Service: $date.<br><br> The Order you submitted is below.<br> Are you 18 years or older? $Eighteen<br> Type Service: $List<br> Date service needed: $Dsn<br> $Title $FnameUc $LnameUc $Suffix<br> $Address<br> $CityState $Zip<br> $Email<br> Daytime Phone: $Phone<br> Evening Phone: $Phone_2<br> <b>Computer Information</b><br> Type Computer: $TypeComputer<br> Computer Brand: $ComputerBrand<br> Computer Model: $ComputerModel<br><br> <b>Items to $List</b><br> $List2[0] $List2[1] $List2[2] $List2[3] $List2[4] $List2[5] $List2[6] $List2[7] $List2[8] $List2[9] $List2[10] $List2[11] <b>Comments</b><br> $Comments<br><br> CONFIRMATION NUMBER: $confirmation_number<br> ORDER NUMBER: $order_num<br> You will need your CONFIRMATION NUMBER to validate your ORDER.<br> <br> </body> </html> EOF; //end of message $headers = "From: $From\r\n"; $headers.= "Content-type: text/html\r\n"; //$headers.= "Cc: [email]horacef@horacefranklinjr.com[/email]"; //options to send to cc+bcc //$headers.= "Cc: [email]email@maaking.cXom[/email]"; //$headers.= "Bcc: [email]email@maaking.cXom[/email]"; // now lets send the email. mail($Email, $subject, $message, $headers); echo " "; } ?>
  8. Has anyone heard of this error and know how to fix it: PHP Parse error: syntax error, unexpected $end on line 268 Line 268: ?> <?php // Process repair_upgradeform.html error_reporting(-1); // Create Random Number srand((double) microtime() * 1000000); //Define Variable(s) $random_number = rand(); $confirmation_number = "$random_number"; $date = date("D d M Y - H:i:s "); $order_date = date("D d M Y"); $SendTo = "coon-a@gmx.com"; $From = "coon-a@gmx.com"; $error_message = ""; //Get Data From Form $Eighteen = $_POST['Eighteen']; $List = $_POST['List']; $Dsn = $_POST['Dsn']; $Title = $_POST['Title']; $Fname = $_POST['Fname']; $Lname = $_POST['Lname']; $Suffix = $_POST['Suffix']; $Address = $_POST['Address']; $CityState = $_POST['CityState']; $Zip = $_POST['Zip']; $Email = $_POST['Email']; $Phone = $_POST['Phone']; $Phone_2 = $_POST['Phone_2']; $TypeComputer = $_POST['TypeComputer']; $ComputerBrand = $_POST['ComputerBrand']; $ComputerModel = $_POST['ComputerModel']; if(isset($_POST['Cd'])) { $Cd = $_POST['Cd']; } if(isset($_POST['Cd_rw'])) { $Cd_rw = $_POST['Cd_rw']; } if(isset($_POST['Dvd'])) { $Dvd = $_POST['Dvd']; } if(isset($_POST['Dvd_rw'])) { $Dvd_rw = $_POST['Dvd_rw']; } if(isset($_POST['GraphicCard'])) { $GraphicCard = $_POST['GraphicCard']; } if(isset($_POST['Memory'])) { $Memory = $_POST['Memory']; } if(isset($_POST['Modem'])) { $Modem = $_POST['Modem']; } if(isset($_POST['Multimedia'])) { $Multimedia = $_POST['Multimedia']; } if(isset($_POST['NetworkCard'])) { $NetworkCard = $_POST['NetworkCard']; } if(isset($_POST['Software'])) { $SoundCard = $_POST['Software']; } if(isset($_POST['SoundCard'])) { $SoundCard = $_POST['SoundCard']; } if(isset($_POST['Speakers'])) { $Speakers = $_POST['Speakers']; } $Comments = $_POST['Comments']; $FnameUc = ucfirst($Fname); $LnameUc = ucfirst($Lname); $order_num = "$order_date-$LnameUc-$confirmation_number"; // validate expected data exists and is in the correct format ($Fname, $Lname, and $Email) if(!isset($_POST['Eighteen'])) { echo "No Age Verification.\n"; die(); } if(!isset($_POST['List'])) { echo "No Type Service.\n"; die(); } if(!isset($_POST['Dsn'])) { echo "No Date Service Needed.\n"; die(); } if(!isset($_POST['Fname'])) { echo "No First Name.\n"; died(); } if(!isset($_POST['Lname'])) { echo "No Last Name.\n"; died(); } if(!isset($_POST['CityState'])) { echo "No City\State.\n"; die(); } if(!isset($_POST['Email'])) { echo "No Email address.\n"; die(); } if (check_email_address($Email)) { //echo $Email . " "; } else { echo $Email . " is not a valid email address.\n"; die(); } // Call Functions Repair_Upgrade_3(); //FUNCTIONS function died() { global $date, $SendTo, $From, $error_message, $confirmation_number, $order_num, $Eighteen, $List, $Dsn, $Title, $Fname, $Lname, $Suffix, $Address, $CityState, $Zip, $Email, $Phone, $Phone_2, $TypeComputer, $ComputerBrand, $ComputerModel, $Cd, $Cd_rw, $Dvd, $Dvd_rw, $GraphicCard, $Memory, $Modem, $Multimedia, $NetworkCard, $Software, $SoundCard, $Speakers, $Comments; // your error code can go here echo "These errors appear below.\n"; echo "<br /><br />\n"; echo "$error_message\n"; echo "<br /><br />\n"; echo "Please go back and fix these errors.\n"; echo "<br /><br />\n"; die(); } $error_message = ""; $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$Fname)) { $error_message.= 'The First Name you entered does not appear to be valid.<br />'; die(); } if(!preg_match($string_exp,$Lname)) { $error_message.= 'The Last Name you entered does not appear to be valid.<br />'; die(); } $string_exp = "/^[A-Za-z0-9 !-.,:;?']+$/"; if(!preg_match($string_exp,$Comments)) { $error_message.= 'You used invalid charaters in the comments box.<br />'; } if(strlen($Comments) < 2) { $error_message.= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { die($error_message); } function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } function check_email_address($Email) { // First, we check that there's one @ symbol, and that the lengths are right if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $Email)) { // Email invalid because wrong number of characters in one section, or wrong number of @ symbols. echo "Email invalid because wrong number of characters in one section, or wrong number of @ symbols.\n"; echo "<br />\n"; return false; } // Split it into sections to make life easier $Email_array = explode("@", $Email); $local_array = explode(".", $Email_array[0]); for ($i = 0; $i < sizeof($local_array); $i++) { if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$",$local_array[$i])) { echo "Split it into sections to make life easier\n"; echo "<br />\n"; return false; } } if (!ereg("^\[?[0-9\.]+\]?$",$Email_array[1])) { // Check if domain is IP. If not, it should be valid domain name //echo "Check if domain is IP. If not, it should be valid domain name\n"; //echo "<br />\n"; $domain_array = explode(".", $Email_array[1]); if(sizeof($domain_array) < 2) { return false; // Not enough parts to domain echo "Not enough parts to domain\n"; echo "<br />\n"; } for ($i = 0; $i < sizeof($domain_array); $i++) { if(!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) { return false; } } } return true; } function Repair_Upgrade_3() { // Email Customer HTML global $date, $SendTo, $From, $error_message, $confirmation_number, $order_num, $Eighteen, $List, $Dsn, $Title, $Fname, $Lname, $Suffix, $Address, $CityState, $Zip, $Email, $Phone, $Phone_2, $TypeComputer, $ComputerBrand, $ComputerModel, $Cd, $Cd_rw, $Dvd, $Dvd_rw, $GraphicCard, $Memory, $Modem, $Multimedia, $NetworkCard, $Software, $SoundCard, $Speakers, $Comments; // Upper case First and last names $FnameUc = ucfirst($Fname); $LnameUc = ucfirst($Lname); //Create Array $List2=array(); if($Cd) { $List2[0]="CD<br>"; } if($Cd_rw) { $List2[1]="CD RW"<br>; } if($Dvd) { $List2[2]="DVD<br>"; } if($Dvd_rw) { $List2[3]="DVD RW<br>"; } if($GraphicCard) { $List2[4]="Graphic Card<br>"; } if($Memory) { $List2[5]="Memory<br>"; } if($Modem) { $List2[6]="Modem<br>"; } if($Multimedia) { $List2[7]="Multimedia<br>"; } if($NetworkCard) { $List2[8]="Network Card<br>"; } if($Software) { $List2[9]="Software<br>"; } if$SoundCard) { $List2[10]="Sound Card<br>"; } if($Speakers) { $List2[11]="Speakers<br><br>"; } $subject = "RE: Repair/Upgrade Order -- HTML\n\n"; //begin of HTML message $message = <<<EOF <html> <body BGCOLOR='tan' TEXT='black'><br> Hello $FnameUc<br> We received your request for Service: $date.<br><br> The Order you submitted is below.<br> You are 18 years or older? $Eighteen<br> Type Service: $List<br> Date service needed: $Dsn<br> $Title $FnameUc $LnameUc $Suffix<br> $Address<br> $CityState $Zip<br> $Email<br> Daytime Phone: $Phone<br> Evening Phone: $Phone_2<br> <b>Computer Information</b><br> Type Computer: $TypeComputer<br> Computer Brand: $ComputerBrand<br> Computer Model: $ComputerModel<br><br> <b>Items to $List</b><br> $List2[0] $List2[1] $List2[2] $List2[3] $List2[4] $List2[5] $List2[6] $List2[7] $List2[8] $List2[9] $List2[10] $List2[11] <b>Comments</b><br> $Comments<br><br> "CONFIRMATION NUMBER: $confirmation_number<br> ORDER NUMBER: $order_num<br> You will need your CONFIRMATION NUMBER to validate your ORDER.<br> <br> </body> </html> EOF; //end of message $headers = "From: $From\r\n"; $headers .= "Content-type: text/html\r\n"; //$headers .= "Cc: [email]coon-a@gmx.com[/email]"; //options to send to cc+bcc //$headers .= "Cc: [email]email@maaking.cXom[/email]"; //$headers .= "Bcc: [email]email@maaking.cXom[/email]"; // now lets send the email. mail($Email, $subject, $message, $headers); echo " "; } ?>
  9. The file exist and is readable and writable "The file is writable" "The file is readable". I changed permissions to rwx and it worked. I will mark solved after a few dozen test <?php // Process repair_upgradeform.html error_reporting(-1); // Create Random Number srand((double) microtime() * 1000000); //Define Variable(s) $random_number = rand(); $confirmation_number = "$random_number"; $date = date("D d M Y - H:i:s "); $order_date = date("D d M Y"); $SendTo = "coon-a@gmx.com"; $From = "coon-a@gmx.com"; $error_message = ""; $myfile = "s_vcs.txt"; if (is_writable($myfile)) { echo ' '; } else { echo 'The file is not writable\n\n'; } if (is_readable($myfile)) { echo ' '; } else { echo 'The file is not readable'; } $handle = fopen($myfile, 'a+') or die("Couldn't open $myfile"); //Get Data From Form $Eighteen = $_POST['Eighteen']; $List = $_POST['List']; $Dsn = $_POST['Dsn']; $Title = $_POST['Title']; $Fname = $_POST['Fname']; $Lname = $_POST['Lname']; $Suffix = $_POST['Suffix']; $Address = $_POST['Address']; $CityState = $_POST['CityState']; $Zip = $_POST['Zip']; $Email = $_POST['Email']; $Phone = $_POST['Phone']; $Phone_2 = $_POST['Phone_2']; $TypeComputer = $_POST['TypeComputer']; $ComputerBrand = $_POST['ComputerBrand']; $ComputerModel = $_POST['ComputerModel']; if(isset($_POST['Cd'])) { $Cd = $_POST['Cd']; } if(isset($_POST['Cd_rw'])) { $Cd_rw = $_POST['Cd_rw']; } if(isset($_POST['Dvd'])) { $Dvd = $_POST['Dvd']; } if(isset($_POST['Dvd_rw'])) { $Dvd_rw = $_POST['Dvd_rw']; } if(isset($_POST['GraphicCard'])) { $GraphicCard = $_POST['GraphicCard']; } if(isset($_POST['Memory'])) { $Memory = $_POST['Memory']; } if(isset($_POST['Modem'])) { $Modem = $_POST['Modem']; } if(isset($_POST['Multimedia'])) { $Multimedia = $_POST['Multimedia']; } if(isset($_POST['NetworkCard'])) { $NetworkCard = $_POST['NetworkCard']; } if(isset($_POST['Software'])) { $SoundCard = $_POST['Software']; } if(isset($_POST['SoundCard'])) { $SoundCard = $_POST['SoundCard']; } if(isset($_POST['Speakers'])) { $Speakers = $_POST['Speakers']; } $Comments = $_POST['Comments']; $FnameUc = ucfirst($Fname); $LnameUc = ucfirst($Lname); $order_num = "$order_date-$LnameUc-$confirmation_number"; // validate expected data exists and is in the correct format ($Fname, $Lname, $Email and $Phone) if(!isset($_POST['Eighteen'])) { echo "No Age Verification."; die(); } if(!isset($_POST['List'])) { echo "No Type Service."; die(); } if(!isset($_POST['Dsn'])) { echo "No Date Service Needed."; die(); } if(!isset($_POST['Fname'])) { echo "No First Name."; died(); } if(!isset($_POST['Lname'])) { echo "No Last Name."; died(); } if(!isset($_POST['CityState'])) { echo "No City\State."; die(); } if(!isset($_POST['Email'])) { echo "No Email address."; die(); } if (check_email_address($Email)) { //echo $Email . " "; } else { echo $Email . " is not a valid email address."; die(); } // Call Functions Repair_Upgrade_1(); //FUNCTIONS function died() { global $date, $SendTo, $From, $error_message, $confirmation_number, $order_num, $Eighteen, $List, $Dsn, $Title, $Fname, $Lname, $Suffix, $Address, $CityState, $Zip, $Email, $Phone, $Phone_2, $TypeComputer, $ComputerBrand, $ComputerModel, $Cd, $Cd_rw, $Dvd, $Dvd_rw, $GraphicCard, $Memory, $Modem, $Multimedia, $NetworkCard, $Software, $SoundCard, $Speakers, $Comments; // your error code can go here echo "These errors appear below.\n"; echo "<br /><br />\n"; echo "$error_message\n"; echo "<br /><br />\n"; echo "Please go back and fix these errors.\n"; echo "<br /><br />\n"; die(); } $error_message = ""; $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$Fname)) { $error_message.= 'The First Name you entered does not appear to be valid.<br />'; die(); } if(!preg_match($string_exp,$Lname)) { $error_message.= 'The Last Name you entered does not appear to be valid.<br />'; die(); } $string_exp = "/^[A-Za-z0-9 !-.,:;?']+$/"; if(!preg_match($string_exp,$Comments)) { $error_message.= 'You used invalid charaters in the comments box.<br />'; } if(strlen($Comments) < 2) { $error_message.= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { die($error_message); } function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } function check_email_address($Email) { // First, we check that there's one @ symbol, and that the lengths are right if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $Email)) { // Email invalid because wrong number of characters in one section, or wrong number of @ symbols. echo "Email invalid because wrong number of characters in one section, or wrong number of @ symbols.\n"; echo "<br />\n"; return false; } // Split it into sections to make life easier $Email_array = explode("@", $Email); $local_array = explode(".", $Email_array[0]); for ($i = 0; $i < sizeof($local_array); $i++) { if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$",$local_array[$i])) { echo "Split it into sections to make life easier\n"; echo "<br />\n"; return false; } } if (!ereg("^\[?[0-9\.]+\]?$",$Email_array[1])) { // Check if domain is IP. If not, it should be valid domain name //echo "Check if domain is IP. If not, it should be valid domain name\n"; //echo "<br />\n"; $domain_array = explode(".", $Email_array[1]); if(sizeof($domain_array) < 2) { return false; // Not enough parts to domain echo "Not enough parts to domain\n"; echo "<br />\n"; } for ($i = 0; $i < sizeof($domain_array); $i++) { if(!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) { return false; } } } return true; } function Repair_Upgrade_1(){ // write order to file s_vcs.txt global $date, $myfile, $handle, $confirmation_number, $order_num, $Eighteen, $List, $Dsn, $Title, $Fname, $Lname, $Suffix, $Address, $CityState, $Zip, $Email, $Phone, $Phone_2, $TypeComputer, $ComputerBrand, $ComputerModel, $Cd, $Cd_rw, $Dvd, $Dvd_rw, $GraphicCard, $Memory, $Modem, $Multimedia, $NetworkCard, $Software, $SoundCard, $Speakers, $Comments; $handle = fopen($myfile,"a+") or die("couldn't open $Myfile"); if(!$handle) { die("couldn't open file <i>$myFile</i>"); } else { $str = "\r\n"; $str.= "NEW RECORD\r\n"; $str.= "Confirmation Number: $confirmation_number\r\n"; $str.= "Order Number: $order_num\r\n"; $str.= "Date: $date\r\n"; $str.= "Age verification: Are you 18 years or older? $Eighteen\r\n"; $str.= "Type Service: $List\r\n"; $str.= "Date Service Needed: $Dsn\r\n"; $str.= "Title: $Title\r\n"; $str.= "First Name: ucfirst($Fname)\r\n"; $str.= "Last Name: ucfirst($Lname)\r\n"; $str.= "Last Name: $Suffix\r\n"; $str.= "Address: $Address\r\n"; $str.= "City, State: $CityState\r\n"; $str.= "Zip Code: $Zip\r\n"; $str.= "Email Address: $Email\r\n"; $str.= "Daytime Phone: $Phone\r\n"; $str.= "Evening Phone: $Phone_2\r\n"; $str.= "Type Computer: $TypeComputer\r\n"; $str.= "Computer Brand: $ComputerBrand\r\n"; $str.= "Computer Model: $ComputerModel\r\n"; $str.= "Items to $List:\r\n"; if($Cd) { $str.= "CD\r\n"; } if($Cd_rw) { $str.= "CD RW\r\n"; } if($Dvd) { $str.= "DVD\r\n"; } if($Dvd_rw) { $str.= "DVD RW\r\n"; } if($GraphicCard) { $str.= "Graphic Card\r\n"; } if($Memory) { $str.= "Memory\r\n"; } if($Modem) { $str.= "Modem\r\n"; } if($Multimedia) { $str.= "Multimedia\r\n"; } if($NetworkCard) { $str.= "Network Card\r\n"; } if($Software) { $str.= "Software\r\n"; } if($SoundCard) { $str.= "Sound Card\r\n"; } if($Speakers) { $str.= "Speakers\r\n\n"; } $str.= "Comments: $Comments\r\n"; $str.= "END OF RECORD\r\n"; $str.= "\r\n"; fwrite($handle, $str); } fclose($handle); } ?>
  10. Yes, the text file and the script are in the same directory. Now I have this PHP notice in addition to the others. PHP Warning: fopen(s_vcs.txt) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: Inappropriate ioctl for device in When it rains it pours! The host server has PHP 52 on it.
  11. The file is not opening. This was in my browser "Couldn't open s_vcs.txt". The 'a+' should append to a file or create the file. Neither set of quotes single ' ' or double " 'are working. I tried both. I do not know why.
  12. Sorry, when I copied line 14 I missed the semicolon. I changed $fp to $handle, still not working. Now, I get this error: PHP Notice: Use of undefined constant †- assumed 'â€' line 15 Line 15: $handle = fopen($myfile, “a+”) or die("Couldn't open $myfile"); <?php // Process repair_upgradeform.html error_reporting(-1); // Create Random Number srand((double) microtime() * 1000000); //Define Variable(s) $random_number = rand(); $confirmation_number = "$random_number"; $date = date("D d M Y - H:i:s "); $order_date = date("D d M Y"); $SendTo = "coon-a@gmx.com"; $From = "coon-a@gmx.com"; $error_message = ""; $myfile = "s_vcs.txt"; $handle = fopen($myfile, “a+”) or die("Couldn't open $myfile"); //Get Data From Form $Eighteen = $_POST['Eighteen']; $List = $_POST['List']; $Dsn = $_POST['Dsn']; $Title = $_POST['Title']; $Fname = $_POST['Fname']; $Lname = $_POST['Lname']; $Suffix = $_POST['Suffix']; $Address = $_POST['Address']; $CityState = $_POST['CityState']; $Zip = $_POST['Zip']; $Email = $_POST['Email']; $Phone = $_POST['Phone']; $Phone_2 = $_POST['Phone_2']; $TypeComputer = $_POST['TypeComputer']; $ComputerBrand = $_POST['ComputerBrand']; $ComputerModel = $_POST['ComputerModel']; if(isset($_POST['Cd'])) { $Cd = $_POST['Cd']; } if(isset($_POST['Cd_rw'])) { $Cd_rw = $_POST['Cd_rw']; } if(isset($_POST['Dvd'])) { $Dvd = $_POST['Dvd']; } if(isset($_POST['Dvd_rw'])) { $Dvd_rw = $_POST['Dvd_rw']; } if(isset($_POST['GraphicCard'])) { $GraphicCard = $_POST['GraphicCard']; } if(isset($_POST['Memory'])) { $Memory = $_POST['Memory']; } if(isset($_POST['Modem'])) { $Modem = $_POST['Modem']; } if(isset($_POST['Multimedia'])) { $Multimedia = $_POST['Multimedia']; } if(isset($_POST['NetworkCard'])) { $NetworkCard = $_POST['NetworkCard']; } if(isset($_POST['Software'])) { $SoundCard = $_POST['Software']; } if(isset($_POST['SoundCard'])) { $SoundCard = $_POST['SoundCard']; } if(isset($_POST['Speakers'])) { $Speakers = $_POST['Speakers']; } $Comments = $_POST['Comments']; $FnameUc = ucfirst($Fname); $LnameUc = ucfirst($Lname); $order_num = "$order_date-$LnameUc-$confirmation_number"; // validate expected data exists and is in the correct format ($Fname, $Lname, $Email and $Phone) if(!isset($_POST['Eighteen'])) { echo "No Age Verification."; die(); } if(!isset($_POST['List'])) { echo "No Type Service."; die(); } if(!isset($_POST['Dsn'])) { echo "No Date Service Needed."; die(); } if(!isset($_POST['Fname'])) { echo "No First Name."; died(); } if(!isset($_POST['Lname'])) { echo "No Last Name."; died(); } if(!isset($_POST['CityState'])) { echo "No City\State."; die(); } if(!isset($_POST['Email'])) { echo "No Email address."; die(); } if (check_email_address($Email)) { //echo $Email . " "; } else { echo $Email . " is not a valid email address."; die(); } // Call Functions Repair_Upgrade_1(); //FUNCTIONS function died() { global $date, $SendTo, $From, $error_message, $confirmation_number, $order_num, $Eighteen, $List, $Dsn, $Title, $Fname, $Lname, $Suffix, $Address, $CityState, $Zip, $Email, $Phone, $Phone_2, $TypeComputer, $ComputerBrand, $ComputerModel, $Cd, $Cd_rw, $Dvd, $Dvd_rw, $GraphicCard, $Memory, $Modem, $Multimedia, $NetworkCard, $Software, $SoundCard, $Speakers, $Comments; // your error code can go here echo "These errors appear below.\n"; echo "<br /><br />\n"; echo "$error_message\n"; echo "<br /><br />\n"; echo "Please go back and fix these errors.\n"; echo "<br /><br />\n"; die(); } $error_message = ""; $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$Fname)) { $error_message.= 'The First Name you entered does not appear to be valid.<br />'; die(); } if(!preg_match($string_exp,$Lname)) { $error_message.= 'The Last Name you entered does not appear to be valid.<br />'; die(); } $string_exp = "/^[A-Za-z0-9 !-.,:;?']+$/"; if(!preg_match($string_exp,$Comments)) { $error_message.= 'You used invalid charaters in the comments box.<br />'; } if(strlen($Comments) < 2) { $error_message.= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { die($error_message); } function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } function check_email_address($Email) { // First, we check that there's one @ symbol, and that the lengths are right if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $Email)) { // Email invalid because wrong number of characters in one section, or wrong number of @ symbols. echo "Email invalid because wrong number of characters in one section, or wrong number of @ symbols.\n"; echo "<br />\n"; return false; } // Split it into sections to make life easier $Email_array = explode("@", $Email); $local_array = explode(".", $Email_array[0]); for ($i = 0; $i < sizeof($local_array); $i++) { if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$",$local_array[$i])) { echo "Split it into sections to make life easier\n"; echo "<br />\n"; return false; } } if (!ereg("^\[?[0-9\.]+\]?$",$Email_array[1])) { // Check if domain is IP. If not, it should be valid domain name //echo "Check if domain is IP. If not, it should be valid domain name\n"; //echo "<br />\n"; $domain_array = explode(".", $Email_array[1]); if(sizeof($domain_array) < 2) { return false; // Not enough parts to domain echo "Not enough parts to domain\n"; echo "<br />\n"; } for ($i = 0; $i < sizeof($domain_array); $i++) { if(!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) { return false; } } } return true; } function Repair_Upgrade_1(){ // write order to file s_vcs.txt global $date, $myfile, $handle, $confirmation_number, $order_num, $Eighteen, $List, $Dsn, $Title, $Fname, $Lname, $Suffix, $Address, $CityState, $Zip, $Email, $Phone, $Phone_2, $TypeComputer, $ComputerBrand, $ComputerModel, $Cd, $Cd_rw, $Dvd, $Dvd_rw, $GraphicCard, $Memory, $Modem, $Multimedia, $NetworkCard, $Software, $SoundCard, $Speakers, $Comments; $handle = fopen($myfile,"a+") or die("couldn't open $Myfile"); rewind($fh); if(!$handle) { die("couldn't open file <i>$myFile</i>"); } else { $str = "\r\n"; $str.= "NEW RECORD\r\n"; $str.= "Confirmation Number: $confirmation_number\r\n"; $str.= "Order Number: $order_num\r\n"; $str.= "Date: $date\r\n"; $str.= "Age verification: Are you 18 years or older? $Eighteen\r\n"; $str.= "Type Service: $List\r\n"; $str.= "Date Service Needed: $Dsn\r\n"; $str.= "Title: $Title\r\n"; $str.= "First Name: ucfirst($Fname)\r\n"; $str.= "Last Name: ucfirst($Lname)\r\n"; $str.= "Last Name: $Suffix\r\n"; $str.= "Address: $Address\r\n"; $str.= "City, State: $CityState\r\n"; $str.= "Zip Code: $Zip\r\n"; $str.= "Email Address: $Email\r\n"; $str.= "Daytime Phone: $Phone\r\n"; $str.= "Evening Phone: $Phone_2\r\n"; $str.= "Type Computer: $TypeComputer\r\n"; $str.= "Computer Brand: $ComputerBrand\r\n"; $str.= "Computer Model: $ComputerModel\r\n"; $str.= "Items to $List:\r\n"; if($Cd) { $str.= "CD\r\n"; } if($Cd_rw) { $str.= "CD RW\r\n"; } if($Dvd) { $str.= "DVD\r\n"; } if($Dvd_rw) { $str.= "DVD RW\r\n"; } if($GraphicCard) { $str.= "Graphic Card\r\n"; } if($Memory) { $str.= "Memory\r\n"; } if($Modem) { $str.= "Modem\r\n"; } if($Multimedia) { $str.= "Multimedia\r\n"; } if($NetworkCard) { $str.= "Network Card\r\n"; } if($Software) { $str.= "Software\r\n"; } if($SoundCard) { $str.= "Sound Card\r\n"; } if($Speakers) { $str.= "Speakers\r\n\n"; } $str.= "Comments: $Comments\r\n"; $str.= "END OF RECORD\r\n"; $str.= "\r\n"; fwrite($handle, $str); } fclose($handle); } ?>
  13. This is the only error I get. PHP Parse error: syntax error, unexpected T_VARIABLE on line 15 Line 14: $myfile = "s_vcs.txt" Line 15: $fh = fopen($myfile, “a+”) or die("Couldn't open $myfile"); Help! What is wrong with the coding in line 15?
  14. I think the problem is with this line: if(isset($_POST['Attachedfile'])){ $Attachedfile = $_POST['Attachedfile']; } I think if I change it to: if(isset($_FILES['Attachedfile']['name'])) { $Attachedfile = $_FILES['Attachedfile']['name']; } It will allow the name of the file to be stored in the variable $Attachedfile. Then I can use that variable elsewhere in the script. I will try that and if it does not work I will give your script a try. Thanks for your sugesstion! - name contains the original path of the user uploaded file.
  15. I think the problem is with this line: if(isset($_POST['Attachedfile'])){ $Attachedfile = $_POST['Attachedfile']; } I think if I change it to: if(isset($_FILES['Attachedfile']['name'])) { $Attachedfile = $_FILES['Attachedfile']; } It will allow the name of the file to be stored in the variable $Attachedfile. Then I can use that variable elsewhere in the script. I will try that and if it does not work I will give your script a try. Thanks for your sugesstion! - name contains the original path of the user uploaded file.
  16. The function (Sendmail_2 () - below) should send an email with an attachment: The variables $Email $Email_2 $Subject $Attachedfile is the information from the form. No Error Message. No Attachment Please tell me what I am doing wrong that prevents the script from attaching the file to the email. <?php // processess Sendmailform.html error_reporting(E_ALL); // Define variables $Date = date("F d, Y"); // Get Data From Form // validate expected data exists if(isset($_POST['Email'])){ $Email = $_POST['Email']; } if(isset($_POST['Email_2'])){ $Email_2 = $_POST['Email_2']; } if(isset($_POST['Subject'])){ $Subject = $_POST['Subject']; } if(isset($_POST['Text'])){ $Text = $_POST['Text']; } if(isset($_POST['Attachedfile'])){ $Attachedfile = $_POST['Attachedfile']; } // Call Function if(!isset($_POST['Attachedfile'])) { // Call Function Sendmail_2(); Sendmail_1(); } // FUNCTION function Sendmail_1() { global $Date, $Email, $Email_2, $Subject, $Text, $Attachedfile; // Print to Browser echo "<html>\n"; echo "<head>\n"; echo "<TITLE>Send Mail</title>\n"; echo "</head>\n"; echo "<BODY BGCOLOR='blue' TEXT='white'>\n"; echo "<table align='center'>\n"; echo "<tr>\n"; echo "<td>\n"; echo "<br /><br /><br /><br /><br /><br /><br /><br />\n"; echo "</td>\n"; echo "</tr>\n"; echo "</table>\n"; echo "<br />\n"; echo "<table width='600' align='center' border='15'>\n"; echo "<tr>\n"; echo "<th align='center' valign='center' colspan='1' width='600'>\n"; echo "<font size='+2'>\n"; echo "~ ~ ~ This is Email you sent ~ ~ ~\n"; echo "</font>\n"; echo "</th>\n"; echo "</tr>\n"; echo "</table>\n"; echo "<table width='600' align='center' border='15'>\n"; echo "<tr>\n"; echo "<th align='right' valign='center' colspan='1' width='250'>\n"; echo "\t To: $Email\n"; echo "<br />\n"; echo "\t (Recipient's Email Address)\n"; echo "</th>\n"; echo "</tr>\n"; echo "<tr>\n"; echo "<th align='right' valign='center' colspan='1' width='250'>\n"; echo "\t From: $Email_2\n"; echo "<br />\n"; echo "\t Sender's Email Address)\n"; echo "</th>\n"; echo "</tr>\n"; echo "<tr>\n"; echo "<th align='right' valign='center' colspan='1' width='250'>\n"; echo "\t Subject: $Subject\n"; echo "</th>\n"; echo "</tr>\n"; echo "<tr>\n"; echo "<th align='right' valign='center' colspan='1' width='250'>\n"; echo "\t Message: $Text\n"; echo "</th>\n"; echo "</tr>\n"; if(isset($_POST['Attachedfile'])) { echo "<tr>\n"; echo "<th align='right' valign='center' colspan='1' width='250'>\n"; echo "\t Attached File: " .basename( $_FILES['Attachedfile']['name']). "\n"; echo "<br />\n"; echo "</th>\n"; echo "</tr>\n"; } echo "</table>\n"; echo "<table width='600' Align='center'>\n"; echo " <tr>\n"; echo "<td width='600' Align='left'>\n"; echo "<br /><br />\n"; echo "Please visit us again <a href=\"http://www.horace-franklin-jr.com\">www.horace-franklin-jr.com <http://www.horace-franklin-jr.com></a>\n"; echo "</td>\n"; echo "</tr>\n"; echo "</table>\n"; echo "</body>\n"; echo "</html>"; } //////////////////////////// // FUNCTION // // Email with Attachment // //////////////////////////// function Sendmail_2(){ global $Email, $Email_2, $Subject, $Text, $Attachedfile; $Attachedfile = basename( $_FILES['Uploadedfile']['name']); if($Attachedfile == basename( $_FILES['Attachedfile']['name'])){ // FUNCTION function died(){ global $Email, $Email_2, $Subject, $Text, $Attachedfile; // your error code can go here echo "These errors appear below.\n"; echo "<br /><br />\n"; echo "$error_message\n"; echo "<br /><br />\n"; echo "Please go back and fix these errors.\n"; echo "<br /><br />\n"; die(); } $error_message = ""; $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$ <mailto:+@[A-Z0-9.-]+\.[A-Z]{2,4}$>"; if(!eregi($email_exp,$Email)){ $error_message.= 'The Email Address you entered does not appear to be valid.<br />'; } if(!eregi($email_exp,$Email_2)){ $error_message.= 'The Email Address you entered does not appear to be valid.<br />'; } if(strlen($Text) < 2){ $error_message.= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0){ die($error_message); } //FUNCTION function clean_string($string){ $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $SendTo = "$Email"; $From = "$Email_2"; $Subject = "$Subject"; //supply the text and html versions of your email message $Text = "$Text\n"; $html = "$Text\n"; //provide path to the file to be attached $file = "/xxxx/xxxxxxxx/public_html/upload/$Attachedfile"; //create a boundary string. It must be unique //so we use the MD5 algorithm to generate a random hash $random_hash = md5(date('r',time())); //define the headers we want passed. Note that they are separated with \r\n $headers = "From: "."<"."$From".">"."\n"; $headers.= "Reply-To: "."<"."$From".">"; $headers.= "CC: "."<"."horace@horace-franklin-jr.com <mailto:horace@horace-franklin-jr.com>".">"; //add boundary string and mime type specification $headers.= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-{$random_hash} \""; //read the atachment file contents into a string, //encode it with MIME base64, //and split it into smaller chunks $attachment = chunk_split(base64_encode(file_get_contents($file))); //define the body of the message. $body = "--PHP-mixed-{$random_hash}\r\n". "Content-Type: multipart/alternative; boundary=\"PHP-alt-{$random_hash}\"\r\n". "--PHP-alt-{$random_hash}\r\n"."Content-Type: text/plain; charset=\"iso-8859-1\"\r\n"."Content-Transfer-Encoding: 7bit\r\n\r\n". "{$message}\r\n\r\n"."--PHP-alt-{$random_hash}\r\n\r\n". "Content-Type: text/html; charset=\"iso-8859-1\"\r\n". "Content-Transfer-Encoding: 7bit\r\n\r\n". "{$html}\r\n\r\n". "--PHP-alt-{$random_hash}--\r\n\r\n"."--PHP-mixed-{$random_hash}\r\n". "Content-Type: ".mime_content_type($file)."; name=\"". basename($file)."\"\r\n"."Content-Transfer-Encoding: base64\r\n". "Content-Disposition: attachment\r\n\r\n"."{$attachment}\r\n". "--PHP-mixed-{$random_hash}--\r\n\r\n"; //send the email $mail_sent = @mail($SendTo, $Subject, $body, $headers); if($mail_sent){ echo $mail_sent; } else{ echo "Email was not sent\n"; } } else { echo "Attachement not sent\n" } } // FUNCTION // Email with Out Attachment function Sendmail_3(){ global $Email, $Email_2, $Subject, $Text; // FUNCTION function died(){ global $Email, $Email_2, $Subject, $Text; // your error code can go here echo "These errors appear below.\n"; echo "<br /><br />\n"; echo "$error_message\n"; echo "<br /><br />\n"; echo "Please go back and fix these errors.\n"; echo "<br /><br />\n"; die(); } $error_message = ""; $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$ <mailto:+@[A-Z0-9.-]+\.[A-Z]{2,4}$>"; if(!eregi($email_exp,$Email)){ $error_message.= 'The Email Address you entered does not appear to be valid.<br />'; } if(!eregi($email_exp,$Email_2)){ $error_message.= 'The Email Address you entered does not appear to be valid.<br />'; } if(strlen($Text) < 2){ $error_message.= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0){ die($error_message); } //FUNCTION function clean_string($string){ $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $SendTo = "$Email\n"; $From = "$Email_2\n"; $Subject = "$Subject\n"; $email_message = "$Text\n"; // create email headers $headers = 'From: '.$Email_2."\r\n". 'Reply-To: '.$Email_2."\r\n" . 'X-Mailer: PHP/' . phpversion(); //send the email $mail_sent = @mail($SendTo, $Subject, $email_message, $headers); if($mail_sent){ echo $mail_sent; } else{ echo "Email was not sent\n"; } } ?>
  17. The attached script should do 4 things: 1. Upload a file to the server [function FileUp ()]. 2. Display users input to the browser [function Sendmail_1()]. 3. Send an email with an attachment [function Sendmail_2()], if a file has been attached. 4. Send an email with out attachment [function Sendmail_3()] . The script will UPLOAD the file [function FileUp()], because it echos 'Success!'. It will not DISPLAY THE USERS INPUT TO THE BROWSER [function Sendmail_1. It will not attach the uploaded file to the email [function Sendmail_2]. Please tell me what I am doing wrong that prevents the script from displaying the users input to the browser and why it will not attached the uploaded file to the email. <?php // processess Sendmailform.html error_reporting(E_ALL); // Define variables $Date = date("F d, Y"); // Get Data From Form // validate expected data exists if(isset($_POST['Email'])){ $Email = $_POST['Email']; } if(isset($_POST['Email_2'])){ $Email_2 = $_POST['Email_2']; } if(isset($_POST['Subject'])){ $Subject = $_POST['Subject']; } if(isset($_POST['Text'])){ $Text = $_POST['Text']; } if(isset($_POST['Attachedfile'])){ $Attachedfile = $_POST['Attachedfile']; } // Call Function if(!isset($_POST['Attachedfile'])) { // Call Function FileUp(); Sendmail_2(); Sendmail_1(); } else { Sendmail_3(); Sendmail_1(); } // FUNCTIONS // Upload File function FileUp(){ global $Date, $Email, $Email_2, $Subject, $Text, $Attachedfile; $target_path = "/xxxx/xxxxxxxx/public_html/upload"; $target_path = $target_path . basename($_FILES['Attachedfile']['name']) ; $ok=1; //This is our size condition if ($Attachedfile > 2097152){ echo "Your file is too large.<br>"; $ok=0; } //This is our limit file type condition if ($Attachedfile == "text/php"){ echo "No PHP files<br>"; $ok=0; } if ($Attachedfile == "application/octet-stream"){ echo "No EXE files<br>"; $ok=0; } //Here we check that $ok was not set to 0 by an error if ($ok==0){ Echo "Sorry your file was not uploaded"; } //If everything is ok we try to upload it else{ if(move_uploaded_file($_FILES['Attachedfile']['tmp_name'], $target_path)){ echo "Success!"; } else{ echo "Sorry, there was a problem uploading your file."; } } } // FUNCTION function Sendmail_1() { global $Date, $Email, $Email_2, $Subject, $Text, $Attachedfile; // Print to Browser echo "<html>\n"; echo "<head>\n"; echo "<TITLE>Send Mail</title>\n"; echo "</head>\n"; echo "<BODY BGCOLOR='blue' TEXT='white'>\n"; echo "<table align='center'>\n"; echo "<tr>\n"; echo "<td>\n"; echo "<br /><br /><br /><br /><br /><br /><br /><br />\n"; echo "</td>\n"; echo "</tr>\n"; echo "</table>\n"; echo "<br />\n"; echo "<table width='600' align='center' border='15'>\n"; echo "<tr>\n"; echo "<th align='center' valign='center' colspan='1' width='600'>\n"; echo "<font size='+2'>\n"; echo "~ ~ ~ This is Email you sent ~ ~ ~\n"; echo "</font>\n"; echo "</th>\n"; echo "</tr>\n"; echo "</table>\n"; echo "<table width='600' align='center' border='15'>\n"; echo "<tr>\n"; echo "<th align='right' valign='center' colspan='1' width='250'>\n"; echo "\t To: $Email\n"; echo "<br />\n"; echo "\t (Recipient's Email Address)\n"; echo "</th>\n"; echo "</tr>\n"; echo "<tr>\n"; echo "<th align='right' valign='center' colspan='1' width='250'>\n"; echo "\t From: $Email_2\n"; echo "<br />\n"; echo "\t Sender's Email Address)\n"; echo "</th>\n"; echo "</tr>\n"; echo "<tr>\n"; echo "<th align='right' valign='center' colspan='1' width='250'>\n"; echo "\t Subject: $Subject\n"; echo "</th>\n"; echo "</tr>\n"; echo "<tr>\n"; echo "<th align='right' valign='center' colspan='1' width='250'>\n"; echo "\t Message: $Text\n"; echo "</th>\n"; echo "</tr>\n"; if(isset($_POST['Attachedfile'])) { echo "<tr>\n"; echo "<th align='right' valign='center' colspan='1' width='250'>\n"; echo "\t Attached File: " .basename( $_FILES['Attachedfile']['name']). "\n"; echo "<br />\n"; echo "</th>\n"; echo "</tr>\n"; } echo "</table>\n"; echo "<table width='600' Align='center'>\n"; echo " <tr>\n"; echo "<td width='600' Align='left'>\n"; echo "<br /><br />\n"; echo "Please visit us again <a href=\"http://www.horace-franklin-jr.com\">www.horace-franklin-jr.com</a>\n"; echo "</td>\n"; echo "</tr>\n"; echo "</table>\n"; echo "</body>\n"; echo "</html>"; } // FUNCTION // Email with Attachment function Sendmail_3(){ global $Email, $Email_2, $Subject, $Text, $Attachedfile; $Attachedfile = basename( $_FILES['Uploadedfile']['name']); if($Attachedfile == basename( $_FILES['Attachedfile']['name'])){ // FUNCTION function died(){ global $Email, $Email_2, $Subject, $Text, $Attachedfile; // your error code can go here echo "These errors appear below.\n"; echo "<br /><br />\n"; echo "$error_message\n"; echo "<br /><br />\n"; echo "Please go back and fix these errors.\n"; echo "<br /><br />\n"; die(); } $error_message = ""; $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$"; if(!eregi($email_exp,$Email)){ $error_message.= 'The Email Address you entered does not appear to be valid.<br />'; } if(!eregi($email_exp,$Email_2)){ $error_message.= 'The Email Address you entered does not appear to be valid.<br />'; } if(strlen($Text) < 2){ $error_message.= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0){ die($error_message); } //FUNCTION function clean_string($string){ $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $SendTo = "$Email"; $From = "$Email_2"; $Subject = "$Subject"; //supply the text and html versions of your email message $Text = "$Text\n"; $html = "$Text\n"; //provide path to the file to be attached $file = "/xxxx/xxxxxxxx/public_html/upload/$Attachedfile"; //create a boundary string. It must be unique //so we use the MD5 algorithm to generate a random hash $random_hash = md5(date('r',time())); //define the headers we want passed. Note that they are separated with \r\n $headers = "From: "."<"."$From".">"."\n"; $headers.= "Reply-To: "."<"."$From".">"; $headers.= "CC: "."<"."horace@horace-franklin-jr.com".">"; //add boundary string and mime type specification $headers.= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-{$random_hash} \""; //read the atachment file contents into a string, //encode it with MIME base64, //and split it into smaller chunks $attachment = chunk_split(base64_encode(file_get_contents($file))); //define the body of the message. $body = "--PHP-mixed-{$random_hash}\r\n". "Content-Type: multipart/alternative; boundary=\"PHP-alt-{$random_hash}\"\r\n". "--PHP-alt-{$random_hash}\r\n"."Content-Type: text/plain; charset=\"iso-8859-1\"\r\n"."Content-Transfer-Encoding: 7bit\r\n\r\n". "{$message}\r\n\r\n"."--PHP-alt-{$random_hash}\r\n\r\n". "Content-Type: text/html; charset=\"iso-8859-1\"\r\n". "Content-Transfer-Encoding: 7bit\r\n\r\n". "{$html}\r\n\r\n". "--PHP-alt-{$random_hash}--\r\n\r\n"."--PHP-mixed-{$random_hash}\r\n". "Content-Type: ".mime_content_type($file)."; name=\"". basename($file)."\"\r\n"."Content-Transfer-Encoding: base64\r\n". "Content-Disposition: attachment\r\n\r\n"."{$attachment}\r\n". "--PHP-mixed-{$random_hash}--\r\n\r\n"; //send the email $mail_sent = @mail($SendTo, $Subject, $body, $headers); if($mail_sent){ echo $mail_sent; } else{ echo "Email was not sent\n"; } } else { echo "Attachement not sent\n" } } // FUNCTION // Email with Out Attachment function Sendmail_3(){ global $Email, $Email_2, $Subject, $Text; // FUNCTION function died(){ global $Email, $Email_2, $Subject, $Text; // your error code can go here echo "These errors appear below.\n"; echo "<br /><br />\n"; echo "$error_message\n"; echo "<br /><br />\n"; echo "Please go back and fix these errors.\n"; echo "<br /><br />\n"; die(); } $error_message = ""; $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$"; if(!eregi($email_exp,$Email)){ $error_message.= 'The Email Address you entered does not appear to be valid.<br />'; } if(!eregi($email_exp,$Email_2)){ $error_message.= 'The Email Address you entered does not appear to be valid.<br />'; } if(strlen($Text) < 2){ $error_message.= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0){ die($error_message); } //FUNCTION function clean_string($string){ $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $SendTo = "$Email\n"; $From = "$Email_2\n"; $Subject = "$Subject\n"; $email_message = "$Text\n"; // create email headers $headers = 'From: '.$Email_2."\r\n". 'Reply-To: '.$Email_2."\r\n" . 'X-Mailer: PHP/' . phpversion(); //send the email $mail_sent = @mail($SendTo, $Subject, $email_message, $headers); if($mail_sent){ echo $mail_sent; } else{ echo "Email was not sent\n"; } } ?>
  18. The objective of the attached script should do 4 things: 1. Upload a file to the server [function FileUp ()]. 2. Display users input to the browser [function Sendmail_1()]. 3. Send an email with an attachment [function Sendmail_2()], if a file has been attached. 4. Send an email with out attachment [function Sendmail_3()] . The script will UPLOAD the file [function FileUp()], because it echos 'Success!'. It will not DISPLAY THE USERS INPUT TO THE BROWSER [function Sendmail_1. It will not attach the uploaded file to the email [function Sendmail_2]. Please tell me what I am doing wrong that prevents the script from displaying the users input to the browser and why it will not attached the uploaded file to the email. <?php // processess Sendmailform.html error_reporting(E_ALL); // Define variables $Date = date("F d, Y"); // Get Data From Form // validate expected data exists if(isset($_POST['Email'])){ $Email = $_POST['Email']; } if(isset($_POST['Email_2'])){ $Email_2 = $_POST['Email_2']; } if(isset($_POST['Subject'])){ $Subject = $_POST['Subject']; } if(isset($_POST['Text'])){ $Text = $_POST['Text']; } if(isset($_POST['Attachedfile'])){ $Attachedfile = $_POST['Attachedfile']; } // Call Function if(!isset($_POST['Attachedfile'])) { // Call Function FileUp(); Sendmail_2(); Sendmail_1(); } else { Sendmail_3(); Sendmail_1(); } // FUNCTIONS // Upload File function FileUp(){ global $Date, $Email, $Email_2, $Subject, $Text, $Attachedfile; $target_path = "/xxxx/xxxxxxxx/public_html/upload"; $target_path = $target_path . basename($_FILES['Attachedfile']['name']) ; $ok=1; //This is our size condition if ($Attachedfile > 2097152){ echo "Your file is too large.<br>"; $ok=0; } //This is our limit file type condition if ($Attachedfile == "text/php"){ echo "No PHP files<br>"; $ok=0; } if ($Attachedfile == "application/octet-stream"){ echo "No EXE files<br>"; $ok=0; } //Here we check that $ok was not set to 0 by an error if ($ok==0){ Echo "Sorry your file was not uploaded"; } //If everything is ok we try to upload it else{ if(move_uploaded_file($_FILES['Attachedfile']['tmp_name'], $target_path)){ echo "Success!"; } else{ echo "Sorry, there was a problem uploading your file."; } } } // FUNCTION function Sendmail_1() { global $Date, $Email, $Email_2, $Subject, $Text, $Attachedfile; // Print to Browser echo "<html>\n"; echo "<head>\n"; echo "<TITLE>Send Mail</title>\n"; echo "</head>\n"; echo "<BODY BGCOLOR='blue' TEXT='white'>\n"; echo "<table align='center'>\n"; echo "<tr>\n"; echo "<td>\n"; echo "<br /><br /><br /><br /><br /><br /><br /><br />\n"; echo "</td>\n"; echo "</tr>\n"; echo "</table>\n"; echo "<br />\n"; echo "<table width='600' align='center' border='15'>\n"; echo "<tr>\n"; echo "<th align='center' valign='center' colspan='1' width='600'>\n"; echo "<font size='+2'>\n"; echo "~ ~ ~ This is Email you sent ~ ~ ~\n"; echo "</font>\n"; echo "</th>\n"; echo "</tr>\n"; echo "</table>\n"; echo "<table width='600' align='center' border='15'>\n"; echo "<tr>\n"; echo "<th align='right' valign='center' colspan='1' width='250'>\n"; echo "\t To: $Email\n"; echo "<br />\n"; echo "\t (Recipient's Email Address)\n"; echo "</th>\n"; echo "</tr>\n"; echo "<tr>\n"; echo "<th align='right' valign='center' colspan='1' width='250'>\n"; echo "\t From: $Email_2\n"; echo "<br />\n"; echo "\t Sender's Email Address)\n"; echo "</th>\n"; echo "</tr>\n"; echo "<tr>\n"; echo "<th align='right' valign='center' colspan='1' width='250'>\n"; echo "\t Subject: $Subject\n"; echo "</th>\n"; echo "</tr>\n"; echo "<tr>\n"; echo "<th align='right' valign='center' colspan='1' width='250'>\n"; echo "\t Message: $Text\n"; echo "</th>\n"; echo "</tr>\n"; if(isset($_POST['Attachedfile'])) { echo "<tr>\n"; echo "<th align='right' valign='center' colspan='1' width='250'>\n"; echo "\t Attached File: " .basename( $_FILES['Attachedfile']['name']). "\n"; echo "<br />\n"; echo "</th>\n"; echo "</tr>\n"; } echo "</table>\n"; echo "<table width='600' Align='center'>\n"; echo " <tr>\n"; echo "<td width='600' Align='left'>\n"; echo "<br /><br />\n"; echo "Please visit us again <a href=\"http://www.horace-franklin-jr.com\">www.horace-franklin-jr.com</a>\n"; echo "</td>\n"; echo "</tr>\n"; echo "</table>\n"; echo "</body>\n"; echo "</html>"; } // FUNCTION // Email with Attachment function Sendmail_3(){ global $Email, $Email_2, $Subject, $Text, $Attachedfile; $Attachedfile = basename( $_FILES['Uploadedfile']['name']); if($Attachedfile == basename( $_FILES['Attachedfile']['name'])){ // FUNCTION function died(){ global $Email, $Email_2, $Subject, $Text, $Attachedfile; // your error code can go here echo "These errors appear below.\n"; echo "<br /><br />\n"; echo "$error_message\n"; echo "<br /><br />\n"; echo "Please go back and fix these errors.\n"; echo "<br /><br />\n"; die(); } $error_message = ""; $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$"; if(!eregi($email_exp,$Email)){ $error_message.= 'The Email Address you entered does not appear to be valid.<br />'; } if(!eregi($email_exp,$Email_2)){ $error_message.= 'The Email Address you entered does not appear to be valid.<br />'; } if(strlen($Text) < 2){ $error_message.= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0){ die($error_message); } //FUNCTION function clean_string($string){ $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $SendTo = "$Email"; $From = "$Email_2"; $Subject = "$Subject"; //supply the text and html versions of your email message $Text = "$Text\n"; $html = "$Text\n"; //provide path to the file to be attached $file = "/xxxx/xxxxxxxx/public_html/upload/$Attachedfile"; //create a boundary string. It must be unique //so we use the MD5 algorithm to generate a random hash $random_hash = md5(date('r',time())); //define the headers we want passed. Note that they are separated with \r\n $headers = "From: "."<"."$From".">"."\n"; $headers.= "Reply-To: "."<"."$From".">"; $headers.= "CC: "."<"."horace@horace-franklin-jr.com".">"; //add boundary string and mime type specification $headers.= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-{$random_hash} \""; //read the atachment file contents into a string, //encode it with MIME base64, //and split it into smaller chunks $attachment = chunk_split(base64_encode(file_get_contents($file))); //define the body of the message. $body = "--PHP-mixed-{$random_hash}\r\n". "Content-Type: multipart/alternative; boundary=\"PHP-alt-{$random_hash}\"\r\n". "--PHP-alt-{$random_hash}\r\n"."Content-Type: text/plain; charset=\"iso-8859-1\"\r\n"."Content-Transfer-Encoding: 7bit\r\n\r\n". "{$message}\r\n\r\n"."--PHP-alt-{$random_hash}\r\n\r\n". "Content-Type: text/html; charset=\"iso-8859-1\"\r\n". "Content-Transfer-Encoding: 7bit\r\n\r\n". "{$html}\r\n\r\n". "--PHP-alt-{$random_hash}--\r\n\r\n"."--PHP-mixed-{$random_hash}\r\n". "Content-Type: ".mime_content_type($file)."; name=\"". basename($file)."\"\r\n"."Content-Transfer-Encoding: base64\r\n". "Content-Disposition: attachment\r\n\r\n"."{$attachment}\r\n". "--PHP-mixed-{$random_hash}--\r\n\r\n"; //send the email $mail_sent = @mail($SendTo, $Subject, $body, $headers); if($mail_sent){ echo $mail_sent; } else{ echo "Email was not sent\n"; } } else { echo "Attachement not sent\n" } } // FUNCTION // Email with Out Attachment function Sendmail_3(){ global $Email, $Email_2, $Subject, $Text; // FUNCTION function died(){ global $Email, $Email_2, $Subject, $Text; // your error code can go here echo "These errors appear below.\n"; echo "<br /><br />\n"; echo "$error_message\n"; echo "<br /><br />\n"; echo "Please go back and fix these errors.\n"; echo "<br /><br />\n"; die(); } $error_message = ""; $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$"; if(!eregi($email_exp,$Email)){ $error_message.= 'The Email Address you entered does not appear to be valid.<br />'; } if(!eregi($email_exp,$Email_2)){ $error_message.= 'The Email Address you entered does not appear to be valid.<br />'; } if(strlen($Text) < 2){ $error_message.= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0){ die($error_message); } //FUNCTION function clean_string($string){ $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $SendTo = "$Email\n"; $From = "$Email_2\n"; $Subject = "$Subject\n"; $email_message = "$Text\n"; // create email headers $headers = 'From: '.$Email_2."\r\n". 'Reply-To: '.$Email_2."\r\n" . 'X-Mailer: PHP/' . phpversion(); //send the email $mail_sent = @mail($SendTo, $Subject, $email_message, $headers); if($mail_sent){ echo $mail_sent; } else{ echo "Email was not sent\n"; } } ?>
  19. I received the following error: Parse error: syntax error, unexpected T_STRING in /home/xxxxxxx/public_html/sendmail.php on line 30 THIS IS LINE 30 ==> Sendmail(); I read this error means there is a missing semicolon, closing bracket, or closing quote. I checked the php file for those errors and i could not find a missing semicolon, closing bracket, or closing quote. I even checked for closing parenthesis to no avail. Maybe it is because I have been working with the file to long and need another pair of eyes.. Please check the php file below (line 30 is marked) for the error indicated by the error message above and tell me what I did wrong. <?php // processess Sendemailform.html error_reporting(E_ALL); // Define variables $Date = date("F d, Y"); // Get Data From Form // validate expected data exists if(isset($_POST['Email'])) { $Email = $_POST['Email']; } if(isset($_POST['Email_2'])) { $Email_2 = $_POST['Email_2']; } if(isset($_POST['Subject'])) { $Subject = $_POST['Subject']; } if(isset($_POST['Text'])) { $Text = $_POST['Text']; } if(isset($_POST['Attachedfile'])) { $Attachedfile = $_POST['Attachedfile']; // Call Function Fileup(); Attachedfile(); LINE 30 ==> Sendmail(); } else { // Call Function Sendmail(); } // Upload File function Fileup() { global $Date, $Yr, $Attachedfile; $target_path = "/home/xxxxxxxxx/public_html/upload"; $target_path = $target_path . basename($_FILES['Attachedfile']['name']) ; $ok=1; //This is our size condition if ($Attachedfile > 2097152) { echo "Your file is too large.<br>"; $ok=0; } //This is our limit file type condition if ($Attachedfile == "text/php") { echo "No PHP files<br>"; $ok=0; } //if ($Attachedfile == "application/octet-stream") { // echo "No EXE files<br>"; // $ok=0; //} //Here we check that $ok was not set to 0 by an error if ($ok==0) { Echo "Sorry your file was not uploaded"; } //If everything is ok we try to upload it else { if(move_uploaded_file($_FILES['Attachedfile']['tmp_name'], $target_path)) { echo "Success!"; } else { echo "Sorry, there was a problem uploading your file."; } } } // FUNCTION function Attachedfile() { global $Date, $Yr, $Attachedfile; // Print to Browser echo "<html>\n"; echo "<head>\n"; echo "<title>Attached File</title>\n"; echo "</head>\n"; echo "<body BGCOLOR='Tan' TEXT='Black'>\n"; echo "<table width='600' Align='center'>\n"; echo "<tr>\n"; echo "<td width='600' Align='center'>\n"; echo "<font size='+2'>~ ~ ~ ATTACHED FILE ~ ~ ~</font>\n"; echo "</td>\n"; echo "</tr>\n"; echo "</table>\n"; echo "<table width='600' Align='center'>\n"; echo " <tr>\n"; echo "<td width='600' Align='left'>\n"; echo "The file you Attached to the email is :$Attachedfile\n"; echo "<br /><br />\n"; echo " Please visit us again <a href=\"http://www.horace-franklin-jr.com\">www.horace-franklin-jr.com</a>\n"; echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " </body>\n"; echo " </html>"; } // FUNCTION function Sendmail() { global $Email, $Email_2, $Subject, $Text, $Attachedfile; // FUNCTION function died() { global $Email, $Email_2, $Subject, $Text, $Attachedfile; // your error code can go here echo "These errors appear below.\n"; echo "<br /><br />\n"; echo "$error_message\n"; echo "<br /><br />\n"; echo "Please go back and fix these errors.\n"; echo "<br /><br />\n"; die(); } $error_message = ""; $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$"; if(!eregi($email_exp,$Email)) { $error_message.= 'The Email Address you entered does not appear to be valid.<br />'; } if(!eregi($email_exp,$Email_2)) { $error_message.= 'The Email Address you entered does not appear to be valid.<br />'; } if(strlen($Text) < 2) { $error_message.= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { die($error_message); } //FUNCTION function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $SendTo = '$Email'; $From = '$Email_2'; $Subject = "$Subject"; //supply the text and html versions of your email message $message = "$Text\n"; $html = "$Text\n"; //provide path to the file to be attached $file = '/home/xxxxxxx/public_html/upload/$Attachedfile'; //create a boundary string. It must be unique //so we use the MD5 algorithm to generate a random hash $random_hash = md5(date('r',time())); //define the headers we want passed. Note that they are separated with \r\n $headers = "From: "."<"."$From".">"."\n"; $headers.= "Reply-To: "."<"."$From".">"; $headers.= "CC: "."<"."horacef@netscape.com".">"; //add boundary string and mime type specification $headers.= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-{$random_hash} \""; //read the atachment file contents into a string, //encode it with MIME base64, //and split it into smaller chunks $attachment = chunk_split(base64_encode(file_get_contents($file))); //define the body of the message. $body = "--PHP-mixed-{$random_hash}\r\n". "Content-Type: multipart/alternative; boundary=\"PHP-alt-{$random_hash}\"\r\n". "--PHP-alt-{$random_hash}\r\n"."Content-Type: text/plain; charset=\"iso-8859-1\"\r\n"."Content-Transfer-Encoding: 7bit\r\n\r\n". "{$message}\r\n\r\n"."--PHP-alt-{$random_hash}\r\n\r\n". "Content-Type: text/html; charset=\"iso-8859-1\"\r\n". "Content-Transfer-Encoding: 7bit\r\n\r\n". "{$html}\r\n\r\n". "--PHP-alt-{$random_hash}--\r\n\r\n"."--PHP-mixed-{$random_hash}\r\n". "Content-Type: ".mime_content_type($file)."; name=\"". basename($file)."\"\r\n"."Content-Transfer-Encoding: base64\r\n". "Content-Disposition: attachment\r\n\r\n"."{$attachment}\r\n". "--PHP-mixed-{$random_hash}--\r\n\r\n"; //send the email $mail_sent = @mail($SendTo, $Subject, $body, $headers); if($mail_sent) { echo $mail_sent; echo "Email Sent\n"; } else { echo "Email was not sent\n"; } } ?> Thanks in advance.
  20. if ($AddName'] == "Add Name") { if ($AddName == "Add Name") { You're right, Thank you!
  21. // Write information to file 1 it is a comment! so i know where I began writing the information to a file
  22. I am receiving the following error: [b]Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/xgasq39z/public_html/guestbk_c.php on line 43[/b] this is line 43 --> $fc = "\n".$Date."\n".$Name."\n".$Church."\n".$City."\n".$State."\n".$Comments."\n"; I am trying to write the data from a form to a text file. What am I doing wrong? The code is below: [code} <?php error_reporting(E_ALL); // Define variables $Date = date("M d, Y"); $file = "my_file.txt"; $Pastor ="Pastor@bbtel.com"; $Webmaster = "horacef@netscape.com"; $Alladdresses = "$Pastor, $Webmaster"; //Get Data From Form $AddName = $_POST['Addname']; $ViewGuestbook = $_POST['Viewguestbk']; if(isset($_POST['Name'])) { $Name = $_POST['Name']; } else { echo " ERROR - You did not enter a Name\n"; } $Church = $_POST['Church']; $City = $_POST['City']; $State = $_POST['State']; if(isset($_POST['Comments'])) { $Comments = $_POST['Comments']; } else { echo " ERROR - You did not enter a Comment\n"; } if(isset($_POST['PastorContact'])) { $PastorContact = $_POST['PastorContact']; } if(isset($_POST['PastorContact_2'])) { $PastorContact_2 = $_POST['PastorContact_2']; } // validation expected data exists if(!isset($_POST['Name']) && !isset($_POST['Comments'])) { echo "Sorry, Name and Comments fields are required."; die; } //Check which button was clicked if ($AddName'] == "Add Name") { [b] // Write Information to File 1[/b] $file_name = "$file"; $fh = fopen($file_name, "a+"); 43 $fc = "\n".$Date."\n".$Name."\n".$Church."\n".$City."\n".$State."\n".$Comments."\n"; fwrite($fh,$fc); fclose($fh); echo "Form data successfully written to file 1"; // Call Functions Guestbk_1(); Guestbk_2(); Guestbk_3(); Guestbk_4(); Guestbk_5(); } else { if ($ViewGuestbook == "View Guest Book") { // Call Functions Guestbk_4(); } // FUNCTIONS // Write Information to File 2 // function Guestbk_1() { // global $Date, $file, $Pastor, $Webmaster, $Alladdresses, $Name, $Church, $City, $State, // $Comments; // if(empty($Name) || empty($Comments)) { // echo "<h3>Sorry Name and Comments fields are required</h3>"; // } // else { // $fh = fopen($file,'a+'); // if(!$fh) { // die("couldn't open file <i>$file</i>"); // } // else { // $str = "\r\n"; // $str.= "$Date\r\n"; // $str.= "Guest: $Name\r\n"; // $str.= "$Church\r\n"; // $str.= "$City, $State\r\n"; // $str.= "$Comments\r\n"; // $str.= "\r\n"; // fwrite($fh, $str); // echo "Form data successfully written to file 2"; // } // fclose($fh); // } // } // FUNCTION function Guestbk_2() { // Notify the Pastor of Entry global $Date, $file, $Pastor, $Webmaster, $Alladdresses, $Name, $Church, $City, $State, $Comments, $PastorContact, $PastorContact_2; $fh = fopen($file,"r"); if(!$fh) { die("couldn't open file <i>$file</i>"); } else { $file = file_get_contents("$file"); } fclose($fh); if(strstr($file,$Date)) { $subject = "New Guestbook Entry"; $email_message = "A new entry has been made to the GUESTBOOK.\n"; if ($PastorContact == "Yes" && $PastorContact_2 != " "){ $email_message.= "$Name would like you to contact them at $PastorContact_2\n"; } else { echo "You did not enter a telephone number.\n"; } // create email headers $headers = "From: ".$Webmaster."\r\n". "Reply-To: ".$Webmaster."\r\n". "X-Mailer: PHP/".phpversion(); $formsent = mail($Webmaster, $subject, $email_message, $headers); if($formsent) { echo $formsent; echo " Thank you, for adding your information to our GUESTBOOK.\n"; } } } // FUNCTION // Display Added Name to Browser function Guestbk_3() { global $Date, $file, $Pastor, $Webmaster, $Alladdresses, $Name, $Church, $City, $State, $Comments, $PastorContact, $PastorContact_2; echo " <html>\n"; echo " <head>\n"; echo " <title> Added Name</title>\n"; echo " </head>\n"; echo " <BODY BGCOLOR='#000080' TEXT='white' link='yellow'>\n"; echo " <table align='center' width='100%'>\n"; echo " <tr>\n"; echo " <td align='center'>\n"; echo " <h1>Thank you for adding your name to our Guestbook</h1>\n"; echo " <br />\n"; echo " <font size='+2'> The information you added to our Guestbook is below.\n"; echo " </font>\n"; echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " <br /><br /><br />\n"; echo " <table width='699' align='center' border='12'>\n"; echo " <tr>\n"; echo " <th align='right' valign='top' colspan='1' width='165'>\n"; echo " Date:\n"; echo " </th>\n"; echo " <th align='left' valign='middle' colspan='1'>\n"; echo " $Date\n"; echo " </th>\n"; echo " </tr>\n"; echo " <th align='right' valign='top' colspan='1' width='165'>\n"; echo " <b>Name: *</b> \n"; echo " </th>\n"; echo " <th align='left' valign='middle' colspan='1'>\n"; echo " $Name\n"; echo " </th>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <th align='right' valign='top' colspan='1' width='165'>\n"; echo " <b>Home Church: </b> \n"; echo " </th>\n"; echo " <th align='left' valign='middle' colspan='1'>\n"; echo " $Church\n"; echo " </th>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <th align='right' valign='top' colspan='1' width='165'>\n"; echo " City, State\n"; echo " </th>\n"; echo " <th align='left' valign='top' colspan='1' width='165'>\n"; echo " <b>$City, $State: </b> \n"; echo " </th>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <th align='right' valign='middle' colspan='1' width='165'>\n"; echo " <b>Comments: *</b> \n"; echo " </th>\n"; echo " <th align='left' valign='middle' colspan='1'>\n"; echo " $Comments\n"; echo " </th>\n"; echo " </tr>\n"; echo " </table>\n"; if($PastorContact == "Yes") { echo " <table align='center'>\n"; echo " <tr>\n"; echo " <td align='center'>\n"; echo " <font size='+2'> The information below <b><u>will not</b></u> be added to the guestbook </font>\n"; echo " </td>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <td align='center'>\n"; echo " <b>Would you like the pastor to contact you?</b> $PastorContact\n"; echo " <br />\n"; if ($PastorContact_2 == " ") { echo " ERROR - You did not enter a Contact Telephone Number.\n"; } else { echo " <b>My telephone number is:</b> $PastorContact_2\n"; } echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; } echo " <BR /><BR />\n"; echo " <table align='center'>\n"; echo " <tr>\n"; echo " <td>\n"; echo " <font size='+2'>\n"; echo " <a href=\"guestbkform_c.html\"><font size='+1' color='yellow'>Guestbook</font></a>\n"; echo " </font>\n"; echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " </body>\n"; echo " </html>\n"; } // FUNCTION // Display Guestbook to Browser function Guestbk_4() { global $file; $filesize = "4096"; $fh = fopen($file,'r'); if(!$fh) { echo "Sorry there was an error please <a href=\"www.horace-franklin-jr.com/webmaster.html\">contact us now</a>"; die("couldn't open file <i>$file</i>"); } else { $con = fread($fh,$filesize($file)); fclose ($fh); echo "<html>\n"; echo "<head>\n"; echo "<title> Guestbook Display</title>\n"; echo "</head>\n"; echo "<body bground='blue' text='white' link='yellow' vlink='red'>\n"; echo "<table align='center'>\n"; echo "<tr>\n"; echo "<td align='center'>\n"; echo "<font size='+2'> Lifeline Temple C.O.G.I.C. - Guestbook</font>\n"; echo "</td>\n"; echo "</tr>\n"; echo "</table>\n"; echo "<table>\n"; echo "<tr>\n"; echo "<td>\n"; echo "$con\n"; echo "<hr>\n"; echo "</td>\n"; echo "</tr>\n"; echo "</table>\n"; echo "<table>\n"; echo "</body>\n"; echo "</html>\n"; } } function Guestbk_5() { // Email Webmaster global $Date; $SendTo = "horace@horace-franklin-jr.com"; $From = "Webmaster@horace-franklin-jr.com"; $Subject = "Lifeline Temple C.O.G.I.C - Guestbook"; //supply the text and html versions of your email message $text = "Review for errors or bad language.\n"; $html = "Review for errors or bad language.\n"; //provide path to the file to be attached $file = '/home/xgasq39z/public_html/g_bk.txt'; //create a boundary string. It must be unique //so we use the MD5 algorithm to generate a random hash $random_hash = md5(date('r',time())); //define the headers we want passed. Note that they are separated with \r\n $headers = "From: "."<"."$From".">"."\n"; $headers.= "Reply-To: "."<"."$From".">"; //add boundary string and mime type specification $headers.= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-{$random_hash}\""; //read the atachment file contents into a string, //encode it with MIME base64, //and split it into smaller chunks $attachment = chunk_split(base64_encode(file_get_contents($file))); //define the body of the message. $body = "--PHP-mixed-{$random_hash}\r\n". "Content-Type: multipart/alternative; boundary=\"PHP-alt-{$random_hash}\"\r\n". "--PHP-alt-{$random_hash}\r\n"."Content-Type: text/plain; charset=\"iso-8859-1\"\r\n"."Content-Transfer-Encoding: 7bit\r\n\r\n". "{$text}\r\n\r\n"."--PHP-alt-{$random_hash}\r\n\r\n". "Content-Type: text/html; charset=\"iso-8859-1\"\r\n". "Content-Transfer-Encoding: 7bit\r\n\r\n". "{$html}\r\n\r\n". "--PHP-alt-{$random_hash}--\r\n\r\n"."--PHP-mixed-{$random_hash}\r\n". "Content-Type: ".mime_content_type($file)."; name=\"". basename($file)."\"\r\n"."Content-Transfer-Encoding: base64\r\n". "Content-Disposition: attachment\r\n\r\n"."{$attachment}\r\n". "--PHP-mixed-{$random_hash}--\r\n\r\n"; //send the email $mail_sent = @mail($SendTo, $Subject, $body, $headers); if($mail_sent){ echo $mail_sent; echo "Thank you!\n"; } else { echo "Email was not sent\n"; } } ?>
  23. Please help me find the error. I have check and rechecked the code for missing semi colons unbalanced () , " ", and {}. I cannot find the error. What The PHP Error Message Says: Parse error: syntax error, unexpected T_STRING in /home/xsaqd94z/public_html/repair_upgrade.php on line 287 See THIS LINE --> in the code below. <?php error_reporting(E_ALL); // Define varibles $Date = date("D d M Y - H:i:s "); $SendTo ="service@horace-franklin-jr.com"; $From = "horace@horace-franklin-jr.com"; $error_message = ""; $MyFile = "my_file.txt"; // validation expected data exists if(!isset($_POST['Email'])) { echo "We are sorry, but there appears to be a problem with the form your submitted."; } if(!isset($_POST['Eighteen'])) { echo "We are sorry, but you are to young to place an order."; } // Create Random Number srand ((double) microtime( )*1000000); $random_number = rand( ); //Define Variable(s) $confirmation_number = "$random_number"; //Get Data From Form $Eighteen = $_POST['Eighteen']; $List = $_POST['List']; $List_2 = $_POST['List_2']; $Dsn = $_POST['Dsn']; $Title = $_POST['Title']; $Fname = $_POST['Fname']; $Lname = $_POST['Lname']; $Address = $_POST['Address']; $CityState = $_POST['CityState']; $Zip = $_POST['Zip']; $Email = $_POST['Email']; $Phone = $_POST['Phone']; $Phone_2 = $_POST['Phone_2']; $TypeComputer = $_POST['TypeComputer']; $ComputerBrand = $_POST['ComputerBrand']; $ComputerModel = $_POST['ComputerModel']; $Cd = $_POST['Cd']; $Cd_rw = $_POST['Cd_rw']; $Cpu = $_POST['Cpu']; $Dvd = $_POST['Dvd']; $Dvd_rw = $_POST['Dvd_rw']; $GraphicCard = $_POST['GraphicCard']; $Memory = $_POST['Memory']; $Modem = $_POST['Modem']; $Monitor = $_POST['Monitor']; $Multimedia = $_POST['Multimedia']; $NetworkCard = $_POST['NetworkCard']; $Printer = $_POST['Printer']; $Scanner = $_POST['Scanner']; $SoundCard = $_POST['SoundCard']; $Speakers = $_POST['Speakers']; $Comments = $_POST['Comments']; // Call Functions Repair_Upgrade_1(); Repair_Upgrade_2(); Repair_Upgrade_3(); //FUNCTIONS function Repair_Upgrade_1(){ // write order to file s_vcs.txt global $Date, $SendTo, $From, $error_message, $MyFile, $confirmation_number, $Eighteen, $List, $List_2, $Dsn, $Title, $Fname, $Lname, $Address, $CityState, $Zip, $Email, $Phone, $Phone_2, $TypeComputer, $ComputerBrand, $ComputerModel, $Cd, $Cd_rw, $Cpu, $Dvd, $Dvd_rw, $GraphicCard, $Memory, $Modem, $Monitor, $Multimedia, $NetworkCard, $Printer, $Scanner, $SoundCard, $Speakers, $Comments; $fh = fopen($MyFile,'a+'); if(!$fh) { die("couldn't open file <i>$MyFile</i>"); } else { rewind($fh); $str = "\r\n"; $str.= "NEW RECORD\r\n"; $str.= "Confirmation Number: $confirmation_number\r\n"; $str.= "Date: $Date\r\n"; $str.= "Age verification: Are you 18 years or older? $Eighteen\r\n"; $str.= "Type Order: $List\r\n"; $str.= "Type Service: $List_2\r\n"; $str.= "Date Service Needed: $Dsn\r\n"; $str.= "Title: $Title\r\n"; $str.= "First Name: $Fname\r\n"; $str.= "Last Name: $Lname\r\n"; $str.= "Address: $Address\r\n"; $str.= "City, State: $CityState\r\n"; $str.= "Zip Code: $Zip\r\n"; $str.= "Email Address: $Email\r\n"; $str.= "Daytime Phone: $Phone\r\n"; $str.= "Evening Phone: $Phone_2\r\n"; $str.= "Type Computer: $TypeComputer\r\n"; $str.= "Computer Brand: $ComputerBrand\r\n"; $str.= "Computer Model: $ComputerModel\r\n"; $str.= "Items to be repaired/replaced/or upgraded\r\n"; if($Cd) { $str.= "CD: Yes\r\n"; } else { $str.= "CD: No\n"; } if($Cd_rw) { $str.= "CD RW: Yes\r\n"; } else { $str.= "CD RW: No\n"; } if($Cpu) { $str.= "CPU: Yes\r\n"; } else { $str.= "CPU: No\n"; } if($Dvd) { $str.= "DVD: Yes\r\n"; } else { $str.= "DVD: No\n"; } if($Dvd_rw) { $str.= "DVD RW: Yes\r\n"; } else { $str.= "DVD RW: No\n"; } if($GraphicCard) { $str.= "Graphic Card: Yes\r\n"; } else { $str.= "Graphic Card: No\n"; } if($Memory) { $str.= "Memory: Yes\r\n"; } else { $str.= "Memory: No\n"; } if($Modem) { $str.= "Modem: Yes\r\n"; } else { $str.= "Modem: No\n"; } if($Monitor) { $str.= "Monitor: Yes\r\n"; } else { $str.= "Monitor: No\n"; } if($Multimedia) { $str.= "Multimedia: Yes\r\n"; } else { $str.= "Multimedia: No\n"; } if($Cd) { $str.= "Network Card: Yes\r\n"; } else { $str.= "Network Card: No\n"; } if($Printer) { $str.= "Printer: Yes\r\n"; } else { $str.= "Printer: No\n"; } if($Scanner) { $str.= "Scanner: Yes\r\n"; } else { $str.= "Scanner: No\n"; } if($SoundCard) { $str.= "Sound Card: Yes\r\n"; } else { $str.= "Sound Card: No\n"; } if($Speakers) { $str.= "Speakers: Yes\r\n"; } else { $str.= "Speakers: No\n"; } $str.= "Comments: $Comments\r\n"; $str.= "END OF RECORD\r\n"; $str.= "\r\n"; fwrite($fh, $str); } fclose($fh); } function Repair_Upgrade_2() { // Email Customer global $Date, $SendTo, $From, $error_message, $MyFile, $confirmation_number, $Eighteen, $List, $List_2, $Dsn, $Title, $Fname, $Lname, $Address, $CityState, $Zip, $Email, $Phone, $Phone_2, $TypeComputer, $ComputerBrand, $ComputerModel, $Cd, $Cd_rw, $Cpu, $Dvd, $Dvd_rw, $GraphicCard, $Memory, $Modem, $Monitor, $Multimedia, $NetworkCard, $Printer, $Scanner, $SoundCard, $Speakers, $Comments; // EDIT THE LINE BELOW AS REQUIRED // $SendTo = "service@horace-franklin-jr.com"; // FUNCTION function died() { global $Date, $SendTo, $From, $error_message, $MyFile, $confirmation_number, $Eighteen, $List, $List_2, $Dsn, $Title, $Fname, $Lname, $Address, $CityState, $Zip, $Email, $Phone, $Phone_2, $TypeComputer, $ComputerBrand, $ComputerModel, $Cd, $Cd_rw, $Cpu, $Dvd, $Dvd_rw, $GraphicCard, $Memory, $Modem, $Monitor, $Multimedia, $NetworkCard, $Printer, $Scanner, $SoundCard, $Speakers, $Comments; // your error code can go here echo "These errors appear below.\n"; echo "<br /><br />\n"; echo "$error_message\n"; echo "<br /><br />\n"; echo "Please go back and fix these errors.\n"; echo "<br /><br />\n"; die(); } $error_message = ""; $string_exp = "^[a-z .'-]+$"; if(!eregi($string_exp,$Fname)) { $error_message.= 'The First Name you entered does not appear to be valid.<br />'; } if(!eregi($string_exp,$Lname)) { $error_message.= 'The Last Name you entered does not appear to be valid.<br />'; } $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$"; if(!eregi($email_exp,$Email)) { $error_message.= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "^[0-9 .-]+$"; if(!eregi($string_exp,$Phone)) { $error_message.= 'The Daytime Phone Number you entered does not appear to be valid.<br />'; } if(!eregi($string_exp,$Phone_2)) { $error_message.= 'The Evening Phone Number you entered does not appear to be valid.<br />'; } if(strlen($Comments) < 2) { $error_message.= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { die($error_message); } //FUNCTION function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $subject = "RE: Repair-Upgrade Order\n\n"; $email_message = "Hello, $Title $Fname $Lname\n"; $email_message.= "Thank you for your order.\n"; $email_message.= "This is what you submitted:\n"; $email_message.= "Age verification: Are you 18 years or older? $Eighteen\n"; $email_message.= "Type Order: $List\n"; $email_message.= "Type Service: $List_2\n"; $email_message.= "Date Service Needed: $Dsn\n"; $email_message.= "Title: $Title\n"; $email_message.= "First Name: ".clean_string($Fname)."\n"; $email_message.= "Last Name: ".clean_string($Lname)."\n"; $email_message.= "Address: $Address\n"; $email_message.= "$CityState $Zip\n"; $email_message.= "Email Address: ".clean_string($Email)."\n"; $email_message.= "Daytime Telephone: ".clean_string($Phone)."\n"; $email_message.= "Evening Telephone: ".clean_string($Phone_2)."\n"; $email_message.= "Type Computer: $TypeComputer\n"; $email_message.= "Computer Brand: $ComputerBrand\n"; $email_message.= "Computer Model: $ComputerModel\n"; $email_message.= "Items to be Repaired\/Replaced\/or Upgraded.\n"; if($Cd) { $email_message.= "CD: Yes\n"; } else { $email_message.= "CD: No\n"; } if($Cd_rw) { $email_message.= "CD RW: Yes\n"; } else { $email_message.= "CD RW: No\n"; } if($Cpu) { $email_message.= "CPU: Yes\n"; } else { $email_message.= "CPU: No\n"; } [i][b]THIS LINE-->[/b][/i] if($Dvd) { $email_message.= "DVD: Yes\n"; } else { $email_message.= "DVD: No\n"; } if($Dvd_rw) { $email_message.= "DVD RW: Yes\n"; } else { $email_message.= "DVD RW: No\n"; } if($Graphic Card) { $email_message.= "Graphic Card: Yes\n"; } else { $email_message.= "Graphic Card: No\n"; } if($Memory) { $email_message.= "Memory: Yes\n"; } else { $email_message.= "Memory: No\n"; } if($Modem) { $email_message.= "Modem: Yes\n"; } else { $email_message.= "Modem: No\n"; } if($Monitor) { $email_message.= "Monitor: Yes\n"; } else { $email_message.= "Monitor: No\n"; } if($Multimedia) { $email_message.= "Multimedia: $Yes\n"; } else { $email_message.= "Multimedia: No\n"; } if($NetworkCard) { $email_message.= "Network Card: Yes\n"; } else { $email_message.= "Network Card: No\n"; } if($Printer) { $email_message.= "Printer: Yes\n"; } else { $email_message.= "Printer: No\n"; } if($Scanner) { $email_message.= "Scanner: Yes\n"; } else { $email_message.= "Scanner: No\n"; } if($SoundCard) { $email_message.= "Sound Card: Yes\n"; } else { $email_message.= "Sound Card: No\n"; } if($Speakers) { $email_message.= "Speakers: Yes\n"; } else { $email_message.= "Speakers: No\n"; } $email_message.= "Comments: ".clean_string($Comments)."\n\n"; $email_message.= "Please VALIDATE your ORDER by clicking the link below.\n"; $email_message.= "You will need your CONFIRMATION NUMBER $confirmation_number to validate your ORDER.\n\n"; $email_message.= "<a href=\"www.horace-franklin-jr.com/valid_repair_upgradeform.html\"> Validate Order</a>\n"; // create email headers $headers = "From: ".$From."\r\n". "Reply-To: ".$From."\r\n". "X-Mailer: PHP/". phpversion(); $formsent = mail($Email, $subject, $email_message, $headers); if ($formsent) { echo $formsent; } else { echo "email was not sent"; } } function Repair_Upgrade_3(){ // Print to browser global $Date, $SendTo, $From, $error_message, $MyFile, $confirmation_number, $Eighteen, $List, $List_2, $Dsn, $Title, $Fname, $Lname, $Address, $CityState, $Zip, $Email, $Phone, $Phone_2, $TypeComputer, $ComputerBrand, $ComputerModel, $Cd, $Cd_rw, $Cpu, $Dvd, $Dvd_rw, $GraphicCard, $Memory, $Modem, $Monitor, $Multimedia, $NetworkCard, $Printer, $Scanner, $SoundCard, $Speakers, $Comments; echo " <html>\n"; echo " <head>\n"; echo " <title>Repair/Upgrade/Replace</title>\n"; echo " </head>\n"; echo " <body BGCOLOR='tan' TEXT='black'>\n"; echo " <table width='700' Align='center'>\n"; echo " <tr>\n"; echo " <td width='700' Align='center'>\n"; echo " <font size='+2'>~ ~ ~ REPAIR/UPGRADE/REPLACE ORDER ~ ~ ~</font>\n"; echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " <table width='700' Align='center'>\n"; echo " <tr>\n"; echo " <td width='700' Align='left'>\n"; echo " Hi $Title $Fname $Lname\n"; echo " <br />\n"; echo " We have received your request for Service - $Date.\n"; echo " <br /><br />\n"; echo " The Order you submitted is below.\n"; echo " Age verification: Are you 18 years or older? $Eighteen\n"; echo " <br />\n"; echo " Type Order: $List\n"; echo " <br />\n"; echo " Type Service: $List_2\n"; echo " <br />\n"; echo " Date service needed: $Dsn\n"; echo " <br />\n"; echo " $Title $Fname $Lname\n"; echo " <br />\n"; echo " $Address\n"; echo " <br />\n"; echo " $CityState $Zip\n"; echo " <br />\n"; echo " $Email\n"; echo " <br />\n"; echo " Daytime Phone: $Phone\n"; echo " <br />\n"; echo " Evening Phone: $Phone_2\n"; echo " <br /><br />\n"; echo " <b>Computer Information</b>\n"; echo " <br />\n"; echo " Type Computer: $TypeComputer\n"; echo " <br />\n"; echo " Computer Brand: $ComputerBrand\n"; echo " <br />\n"; echo " Computer Model: $ComputerModel\n"; echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " <br />\n"; echo " <table width='700' align='center'>\n"; echo " <tr>\n"; echo " <td width='700' align='left'>\n"; echo " <b>Items to be Repaired/Replaced/Upgraded</b>\n"; echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " <table width='700' align='center'>\n"; echo " <tr>\n"; echo " <td width='233' align='left'>\n"; if($Cd) { echo " CD: Yes\n"; } else { echo " CD: No\n"; } echo " </td>\n"; echo " <td width='233' align='left'>\n"; if($Cd_rw) { echo " CD RW: Yes\n"; } else { echo " CD RW: No\n"; } echo " </td>\n"; echo " <td width='233' align='left'>\n"; if($Cpu) { echo " CPU: Yes\n"; } else { echo " CPU: No\n"; } echo " </td>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <td width='233' align='left'>\n"; if($Dvd) { echo " DVD: Yes\n"; } else { echo " DVD: No\n"; } echo " </td>\n"; echo " <td width='233' align='left'>\n"; if($Dvd_rw) { echo " DVD RW: Yes\n"; } else { echo " DVD RW: No\n"; } echo " </td>\n"; echo " <td width='233' align='left'>\n"; if($GraphicCard) { echo " Graphic Card: Yes\n"; } else { echo " Graphic Card: No\n"; } echo " </td>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <td width='233' align='left'>\n"; if($Memory) { echo " Memory: Yes\n"; } else { echo " Memory: No\n"; } echo " </td>\n"; echo " <td width='233' align='left'>\n"; if($Modem) { echo " Modem: Yes\n"; } else { echo " Modem: No\n"; } echo " </td>\n"; echo " <td width='233' align='left'>\n"; if($Monitor) { echo " Monitor: Yes\n"; } else { echo " Monitor: No\n"; } echo " </td>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <td width='233' align='left'>\n"; if($Multimedia) { echo " Multimedia: Yes\n"; } else { echo " Multimedia: No\n"; } echo " </td>\n"; echo " <td width='233' align='left'>\n"; if($NetworkCard) { echo " Network Card: Yes\n"; } else { echo " Network Card: No\n"; } echo " </td>\n"; echo " <td width='233' align='left'>\n"; if($Printer) { echo " Printer: Yes\n"; } else { echo " Printer: No\n"; } echo " </td>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <td width='233' align='left'>\n"; if($Scanner) { echo " Scanner: Yes\n"; } else { echo " Scanner: No\n"; } echo " </td>\n"; echo " <td width='233' align='left'>\n"; if($SoundCard) { echo " Sound Card: Yes\n"; } else { echo " Sound Card: No\n"; } echo " </td>\n"; echo " <td width='233' align='left'>\n"; if($Speakers) { echo " Speakers: Yes\n"; } else { echo " Speakers: No\n"; } echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " <table width='700' align='center'>\n"; echo " <tr>\n"; echo " <td width='700' align='left'>\n"; echo " <b>Comments</b>\n"; echo " <br />\n"; echo " $Comments\n"; echo " <br /><br />\n"; echo " Your CONFIRMATION NUMBER: $confirmation_number\n"; echo " <br /><br />\n"; echo " You will receive an email to validate your information.\n"; echo " <br /><br />\n"; echo " Please visit us again <a href=\"http://www.horace-franklin-jr.com\">www.horace-franklin-jr.com</a>\n"; echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " </body>\n"; echo " </html>\n"; } ?>
  24. I looked at the file and this is what it looks like: Mon 07 Dec 2009 , Mon 07 Dec 2009 , Tue 08 Dec 2009 , Tue 08 Dec 2009 I do not understand why the other information was not written to the file. the function Guest_bk() should have written the information to the file guestbook.txt //FUNCTIONS function Guestbk_1(){ // write to file guestbook.txt global $Date, $Name, $Church, $City, $State, $Comments; $MyFile = "guestbook.txt"; $fh = fopen($MyFile,'a+'); if(!$fh) { die("couldn't open file <i>$MyFile</i>"); } else { rewind($fh); $str = "\n"; $str.= "\t\t\t\t\t$Date\n"; $str.= "\t\t\t\t\t$Name\n"; $str.= "\t\t\t\t\t$Church\n"; $str.= "\t\t\t\t\t$City\n"; $str.= "\t\t\t\t\t$State\n"; $str.= "\t\t\t\t\t$Comments\n"; $str.= "\n"; fwrite($fh, $str); echo "success writing to file"; } fclose($fh); } function Guestbk_3() { // Display Guestbook Entries to Browser $MyFile = "guestbook.txt"; $fh = fopen($MyFile,"r"); rewind($fh); if(!$fh) { die("couldn't open file <i>$MyFile</i>"); } else { $file = file_get_contents("$MyFile"); } fclose($fh); if(strstr($file,$Date)) { echo "<html>\n"; echo " <head>\n"; echo " <title>Guestbook Entries</title>\n"; echo " </head>\n"; echo " <body BGCOLOR=\"blue\" TEXT=\"white\">\n"; echo " <table align=\"center\">\n"; echo " <tr>\n"; echo " <td align=\"center\">\n"; echo " <font size=\"+2\">~ ~ ~ GUESTBOOK ENTRIES ~ ~ ~</FONT>\n"; echo " <br /><br />\n"; echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " <table align=\"center\" width=\"600\">\n"; echo " <tr>\n"; echo " <td align=\"left\">\n"; echo " $file\n"; echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " </body>\n"; echo " </html>"; } }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.