Need help with "REST" HTTP POST?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • mobilejack101
    Staff Sergeant

    • Oct 2007
    • 41

    #16
    Re: Need help with "REST" HTTP POST?

    Naval I cant find the line...

    "Paste the code JUST BEFORE this line:"

    header("Location: $returnpage");


    The only place I can find the line is in the code you posted.

    I dont see it in my "ABVFP/dbts_abvfp.php" folder or in the "submit leads" PHP code?

    Am I missing something here?

    Please help!

    Jaco
    Don't miss the game for fear of striking out...

    Comment

    • navaldesign
      General & Forum Moderator

      • Oct 2005
      • 12080

      #17
      Re: Need help with "REST" HTTP POST?

      You need to open the dbts_abvfp.php file that you can find in the ABVFP zip. Then you need to edit it as suggested above, and last, you need to upload the edited file into your site ABVFP folder (replacing the existing one).
      Navaldesign
      Logger Lite: Low Cost, Customizable, multifeatured Login script
      Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
      DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
      Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

      Comment

      • mobilejack101
        Staff Sergeant

        • Oct 2007
        • 41

        #18
        Re: Need help with "REST" HTTP POST?

        Thanks

        Sorry its hard for me as a novice to always understand what you mean..

        Hope fully I will get it right soon!

        Some times I want to slice my wrists with a wet Marri biscuits LOL!

        I will get back to you...

        Thank you for your understanding and time!

        Jaco
        Don't miss the game for fear of striking out...

        Comment

        • mobilejack101
          Staff Sergeant

          • Oct 2007
          • 41

          #19
          Re: Need help with "REST" HTTP POST?

          Naval if I change those lines....
          from.....

          "$postargs .= '&loanamount='.urlencode("R8000-****00 Personal Loan"); "

          to.......

          "$postargs .= '&loanamount='.urlencode($_POST['loanamount']); "
          my loanamount droplist name is "Loan_Amount-R[]"

          How will it look after the change?

          Can I use the capital letters? Underscores? The "-" and the "R" and the "[]"?

          I am not sure what is alowed and what not...

          Please help!

          Jaco
          Don't miss the game for fear of striking out...

          Comment

          • navaldesign
            General & Forum Moderator

            • Oct 2005
            • 12080

            #20
            Re: Need help with "REST" HTTP POST?

            Make it

            $postargs .= '&loanamount='.urlencode($_POST['Loan_Amount-R']);

            Do NOT add the [] and eliminate also from your form, the load amount and type can NOT be a multiple choice listbox, only one choice is allowed....
            Navaldesign
            Logger Lite: Low Cost, Customizable, multifeatured Login script
            Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
            DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
            Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

            Comment

            • mobilejack101
              Staff Sergeant

              • Oct 2007
              • 41

              #21
              Re: Need help with "REST" HTTP POST?

              This is what the code looks like now....

              When I click submit, I get a error message...

              Parse error: syntax error, unexpected '}' in /home/gcumjcjh/public_html/ABVFP/dbts_abvfp.php on line 37

              What is wrong?

              Help please!



              <?php
              # ----------------------------------------------------
              # -----
              # ----- This script was created by DB Technosystems.com
              # -----
              # ----- http://www.dbtechnosystems.com
              # -----
              # ----------------------------------------------------

              error_reporting(55);
              session_start();
              //--- For debugging purposes only----
              //echo "Opened file abvfp.php";
              //exit;
              //putenv("TZ=Europe/Rome"); // Change to whatever yout timezone is
              require ("dbts_ABVFP_config.php");

              //--- For debugging purposes only----
              //echo "Opened config file abvfp.php";
              //exit;
              $dbts_Formid = $_POST['Formid'];
              //--- For debugging purposes only----
              //echo "dbts_Formid = testing $dbts_Formid testing";
              //exit;
              $dbts_Formurl1 = $_SERVER['HTTP_REFERER'];
              //--- For debugging purposes only----
              if ($dbts_Formid == "") {
              $dbts_error = "I cannot process the form. The form has not been correctly setup. !";
              $_SESSION[error] = $dbts_error ;
              header("Location: dbts_ABVFP_errorpage.php");
              }
              $db = mysql_connect($db_host, $db_user, $db_password);
              if ($db == FALSE){
              $dbts_error = "Could not connect to the Database Server. Please check user details !";
              $_SESSION[error] = $dbts_error ;
              mysql_close($db);
              header("Location: dbts_ABVFP_errorpage.php");
              exit;
              }
              mysql_select_db($db_name, $db);
              if (!mysql_select_db($db_name, $db)) {
              $dbts_error = "Could not select Database. Please check user details !";
              $_SESSION[error] = $dbts_error ;
              mysql_close($db);
              header("Location: dbts_ABVFP_errorpage.php");
              }
              $query = "SELECT Formid, Formname, Site, Formurl, Max_filesize, Uploadfolder, Emailaddress, EmailSubject, Emailheader, Emailfooter, Thankyoupage, Errorpage, Autoresponder, Include_email, Autoresponder_EmailSubject, Autoresponder_From, Autoresponder_Emailheader, Autoresponder_Emailfooter, Database_Store FROM ABVFP_Forms WHERE Formid= '$dbts_Formid'";
              $result = mysql_query($query, $db);
              $row = mysql_fetch_array($result, MYSQL_ASSOC);
              if ($row =="") {
              $dbts_error = "I cannot process the form. The form has not been correctly setup. !";
              $_SESSION[error] = $dbts_error ;
              mysql_close($db);
              header("Location: dbts_ABVFP_errorpage.php");
              }
              //mysql_close($db);
              //--- For debugging purposes only----
              //echo "Finished connecting to the DB";
              //exit;
              // -------- RECEIVIMG CONFIGURATION VARIABLES FROM THE DB -----------

              $ndsite = $row[Site] ;
              $ndformurl = $row[Formurl] ;
              $ndfilesize = $row[Max_filesize] ;
              $ndmailsubject = $row[EmailSubject] ;
              $ndmailfirstline = $row[Emailheader] ;
              $ndmaillastline = $row[Emailfooter] ;
              $autoresponderfirstline = $row[Autoresponder_Emailheader] ;
              $autoresponderlastline = $row[Autoresponder_Emailfooter] ;
              $autoresponder = $row[Autoresponder] ;
              $autoresponderfrom = $row[Autoresponder_From] ;
              $autorespondersubject = $row[Autoresponder_EmailSubject] ;
              $nduploadfolder = $row[Uploadfolder] ;
              $returnpage = $row[Thankyoupage] ;
              $errorpage = $row[Errorpage] ;
              $ndmailaddress = $row[Emailaddress] ;
              $ndincludeemail = $row[Include_email] ;
              $ndDatabase_Store = $row[Database_Store] ;
              //Finding out if there are more than email addresses to receive the email

              $ndmailaddress1 = explode(",", $ndmailaddress);
              //Setting the autoresponder "From" email address
              if (count($ndmailaddress1 ==0))
              {
              $ndmailaddress2 = $ndmailaddress;
              }
              if (count($ndmailaddress1 >=1)) {
              $ndmailaddress2 = $ndmailaddress1[0];
              }
              if ($ndformurl1 != "") {
              if ($ndformurl1 != $ndformurl) {
              $nderror = "Illegal Form Submission \n";
              }
              }
              //--- For debugging purposes only----
              //echo "Finished field examining";
              //exit;
              // -------- RECEIVIMG FIELDNAMES VALUES AND VALIDATION DETAILS------

              $internalfields = array ("submit", "reset", "Formid", "Submit", "SUBMIT", "RESET", "Reset");
              $i = "0";
              reset ($HTTP_POST_VARS);
              while (list ($key, $val) = each ($HTTP_POST_VARS)) {
              if (!in_array($key, $internalfields)) {
              $fieldname = trim($key);
              $fieldlenght = strlen(trim($key));
              $realfieldlength = $fieldlenght;
              if (substr($fieldname, -3, 1) == "-") {
              $ndLast = substr($fieldname, -1, 1);
              if ($ndLast == "R") {
              $R[$i] = "R";
              $V[$i] = substr($fieldname, -2, 1);
              } else {
              $V[$i] = substr($fieldname, -1, 1);
              $R[$i] = substr($fieldname, -2, 1);
              }
              $realfieldlength = $fieldlenght-3;
              }
              if (substr($fieldname, -2, 1) == "-") {
              $ndLast = substr($fieldname, -1, 1);
              if ($ndLast == "R") {
              $R[$i] = "R";
              } else {
              $V[$i] = substr($fieldname, -1, 1);
              }
              $realfieldlength = $fieldlenght-2;
              }

              // ------ Checking for miltiple Choice Values ---------
              @$fieldvalue = $_POST[$key];
              if (is_array($fieldvalue)) {
              @$fieldvalue = @implode(", ",$_POST[$key]);
              }
              // ----Setting the clear Field Names and Values-------
              $fieldname = substr($key, 0, $realfieldlength);
              if ($fieldname == "Email")
              {
              $ndemail = $fieldvalue;
              }
              $ndfieldname[] = $fieldname;
              $ndfieldname_final[] = str_replace("_", " ", $fieldname);
              $ndfieldvalue[] = $fieldvalue;
              $i = $i + 1 ;
              }
              }

              //--- For debugging purposes only----
              //echo "Finished field examining";
              //exit;
              // ------RECEIVING FILE VARIABLES--------------------

              reset ($_FILES);
              $i = 0;
              while (list ($key, $val) = each ($_FILES)) {
              if ($_FILES[$key]['name']!="") {
              $upload_Name1 = ($_FILES[$key]['name']);
              $upload_Name[] = str_replace(" ", "_", $upload_Name1);
              $upload_Size[] = ($_FILES[$key]['size']);
              $upload_Temp[] = ($_FILES[$key]['tmp_name']);
              $upload_Type[] = ($_FILES[$key]['type']);
              $uploadlink[] = "$nduploadfolder/$upload_Name[$i] \n";
              $ndfieldname[] = $key;
              $ndfieldname_final[] = str_replace("_", " ", $key);
              $ndfieldvalue[] = $uploadlink[$i];
              // if the upload succeded, the file will exist
              if (file_exists($upload_Temp[$i])){
              // check to make sure that it is an uploaded file and not a system file
              if(is_uploaded_file($upload_Temp[$i])){
              // open the file for a binary read
              $file = fopen($upload_Temp[$i],'rb');
              // read the file content into a variable
              $data1 = fread($file,filesize($upload_Temp[$i]));
              // close the file
              fclose($file);
              // now we encode it and split it into acceptable length lines
              $data[] = chunk_split(base64_encode($data1));
              }
              $i = $i + 1;
              }
              }
              }

              function RecursiveMkdir($path)
              {
              if (!file_exists($path)) {
              RecursiveMkdir(dirname($path));
              mkdir($path, 0777);
              }
              }
              //--- For debugging purposes only----
              //echo "Finished uploading attached files ";
              //exit;

              // ------------VALIDATION OF THE FIELDS----------------
              // ------------CHECKING FOR REQUIRED FIELDS----------
              $i = 0;
              for ($i = 0; $i < count($ndfieldname); $i++) {
              if ($R[$i] == "R") {
              if (strlen($ndfieldvalue[$i]) == 0) {
              $nderror .= "The field $ndfieldname[$i] is missing !\n";
              }
              }

              // ------------CHECKING FOR CORRECT EMAIL FIELDS----------

              if ($V[$i] == "e") {
              $fieldtype[$i] = "VARCHAR (100)" ;
              if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $ndfieldvalue[$i])) {
              $nderror .= "Your Email seems incorrect !\n";
              }
              if (substr_count($ndfieldvalue[$i] , '@') > 1) {
              $nderror .= "The field $ndfieldname[$i] can only contain the @ character once !\n";
              }
              }
              // ------------CHECKING FOR NUMERIC FIELDS----------

              if ($V[$i] == "N") {
              $fieldtype[$i] = "INT" ;
              if ($ndfieldvalue[$i] != "") {
              if (!is_numeric($ndfieldvalue[$i])) {
              $nderror .= "The field $ndfieldname[$i] should be only numbers / No spaces allowed $nerror !\n";
              }
              }
              }
              // ------------CHECKING FOR FIELD SIZE UP TO 30 WITHOUT EMAIL ----------
              if ($V[$i] == "A") {
              $fieldtype[$i] = "VARCHAR (30)" ;
              if (strlen($ndfieldvalue[$i]) >= 30) {
              $nderror .= "The field $ndfieldname[$i] must be less than 30 characters !\n";
              }
              if (substr_count($ndfieldvalue[$i] , '@') > 0) {
              $nderror .= "The field $ndfieldname[$i] cannot contain the @ character !\n";
              }
              }
              // ------------CHECKING FOR FIELD SIZE UP TO 60 WITHOUT EMAIL ----------
              if ($V[$i] == "B") {
              $fieldtype[$i] = "VARCHAR (60)" ;
              if (strlen($ndfieldvalue[$i]) >= 60) {
              $nderror .= "The field $ndfieldname[$i] must be less than 60 characters !\n";
              }
              if (substr_count($ndfieldvalue[$i] , '@') > 0) {
              $nderror .= "The field $ndfieldname[$i] cannot contain the @ character !\n";
              }
              }
              // ------------CHECKING FOR FIELD SIZE UP TO 200 WITHOUT EMAIL ----------
              if ($V[$i] == "C") {
              $fieldtype[$i] = "VARCHAR (250)" ;
              if (strlen($ndfieldvalue[$i]) >= 200) {
              $nderror .= "The field $ndfieldname[$i] must be less than 200 characters !\n";
              }
              if (substr_count($ndfieldvalue[$i] , '@') > 0) {
              $nderror .= "The field $ndfieldname[$i] cannot contain the @ character !\n";
              }
              }

              // ------------CHECKING FOR FIELD SIZE UP TO 500 WITHOUT EMAIL ----------

              if ($V[$i] == "D") {
              $fieldtype[$i] = "MEDIUMTEXT" ;
              if (strlen($ndfieldvalue[$i]) >= 500) {
              $nderror .= "The field $ndfieldname[$i] must be less than 500 characters !\n";
              }
              if (substr_count($ndfieldvalue[$i] , '@') > 0) {
              $nderror .= "The field $ndfieldname[$i] cannot contain the @ character !\n";
              }
              }
              // ------------CHECKING FOR UNLIMITED FIELD SIZE WITHOUT EMAIL ----------
              if ($V[$i] == "E") {
              $fieldtype[$i] = "TEXT" ;
              if (substr_count($ndfieldvalue[$i] , '@') > 0) {
              $nderror .= "The field $ndfieldname[$i] cannot contain the @ character !\n";
              }
              }
              // ------------CHECKING FOR FIELD SIZE UP TO 30 WITH ONE EMAIL ----------
              if ($V[$i] == "F") {
              $fieldtype[$i] = "VARCHAR (30)" ;
              if (strlen($ndfieldvalue[$i]) >= 30) {
              $nderror .= "The field $ndfieldname[$i] must be less than 30 characters !\n";
              }
              if (substr_count($ndfieldvalue[$i] , '@') > 1) {
              $nderror .= "The field $ndfieldname[$i] can only contain the @ character once !\n";
              }
              }

              // ------------CHECKING FOR FIELD SIZE UP TO 60 WITH ONE EMAIL ----------
              if ($V[$i] == "G") {
              $fieldtype[$i] = "VARCHAR (60)" ;
              if (strlen($ndfieldvalue[$i]) >= 60) {
              $nderror .= "The field $ndfieldname[$i] must be less than 60 characters !\n";
              }
              if (substr_count($ndfieldvalue[$i] , '@') > 1) {
              $nderror .= "The field $ndfieldname[$i] can only contain the @ character once !\n";
              }
              }
              // ------------CHECKING FOR FIELD SIZE UP TO 200 WITH ONE EMAIL ----------
              if ($V[$i] == "H") {
              $fieldtype[$i] = "VARCHAR (250)" ;
              if (strlen($ndfieldvalue[$i]) >= 200) {
              $nderror .= "The field $ndfieldname[$i] must be less than 200 characters !\n";
              }
              if (substr_count($ndfieldvalue[$i] , '@') > 1) {
              $nderror .= "The field $ndfieldname[$i] can only contain the @ character once !\n";
              }
              }
              // ------------CHECKING FOR FIELD SIZE UP TO 500 WITH ONE EMAIL ----------
              if ($V[$i] == "J") {
              $fieldtype[$i] = "TEXT" ;
              if (strlen($ndfieldvalue[$i]) >= 500) {
              $nderror .= "The field $ndfieldname[$i] must be less than 500 characters !\n";
              }
              if (substr_count($ndfieldvalue[$i] , '@') > 1) {
              $nderror .= "The field $ndfieldname[$i] can only contain the @ character once !\n";
              }
              }
              // ------------CHECKING FOR UNLIMITED FIELD SIZE WITH ONE EMAIL ----------
              if ($V[$i] == "I") {
              $fieldtype[$i] = "TEXT" ;
              if (substr_count($ndfieldvalue[$i] , '@') > 1) {
              $nderror .= "The field $ndfieldname[$i] can only contain the @ character once !\n";
              }
              }
              if ($V[$i] == "") {
              $fieldtype[$i] = "VARCHAR (250)";
              }
              }
              // ------------CHECKING FOR MAX UPLOADED FILE SIZE ----------------------
              $ndfilesize1= $ndfilesize*1024;
              for ($i = 0; $i < count($upload_Name); $i++) {
              if ($upload_Name[$i] != "" ) {
              if ($upload_Size[$i] >= $ndfilesize1) {
              $nderror .= "The size of $upload_Name[$i] is bigger than the allowed $ndfilesize Kb !\n";
              }
              }

              }
              if ($nderror != "") {
              $_SESSION[error] = $nderror ;
              header("Location: $errorpage");
              exit;
              }
              //--- For debugging purposes only----
              //echo "Finished validation of the fields ";
              //exit;


              //--------- Move the files to destination----------------
              $nduploadfolder1 = basename($nduploadfolder);
              for ($i = 0; $i < count($upload_Name); $i++) {
              if ($upload_Size[$i] < $ndfilesize1 and $upload_Size[$i] >0)
              {
              $uploadFile = "$nduploadfolder1/".$upload_Name[$i];
              if (!is_dir(dirname($uploadFile)))
              {
              @RecursiveMkdir(dirname($uploadFile));
              }
              else
              {
              @chmod(dirname($uploadFile), 0777);
              }
              @move_uploaded_file( $upload_Temp[$i] , $uploadFile);
              chmod($uploadFile, 0644);
              }
              }
              //--- For debugging purposes only----
              //echo "Finished uploading files ";
              //exit;
              //------------- Find Server date and Time--------------------
              $date = date("l jS F Y, g:i A");
              $Submission_Date = date("F/d/Y");
              //----------------- Find Browser and IPaddress --------------
              $browser =$_SERVER['HTTP_USER_AGENT'];
              $ip = $_SERVER['REMOTE_ADDR'];


              // ---- STORING FIELD VALUES IN THE DATABASE TABLE ---------------
              if ($ndDatabase_Store == "Yes") {
              $dbts_table = "Form_Nr_$dbts_Formid";
              // Check if the table exists already ------------

              $result = mysql_list_tables($db_name);
              while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
              {
              $key= "Tables_in_$db_name";
              $tablename[] = $row[$key];
              }
              //--- For debugging purposes only----
              //print_r($tablename);
              //exit;
              if (!in_array($dbts_table, $tablename)) {
              $query = "CREATE TABLE `$dbts_table` (";
              $query .='`Record_Nr` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, ';
              for ($i = 0; $i < (count($ndfieldname) - count($upload_Name)); $i++) {
              //$ndmailbody .= "$ndfieldname[$i] = $ndfieldvalue[$i] \r\n";
              $query .= "`$ndfieldname[$i]` $fieldtype[$i], ";
              }
              $query .='`Submission_Date` VARCHAR (20),';
              $query .='`IP_Address` VARCHAR (15)';
              $query .=' )'
              . ' ENGINE = myisam;';
              }
              //--- For debugging purposes only----
              //echo "Query = $query****";
              //exit;
              if (mysql_query($query, $db)){
              $message = "Installation completed";
              }
              else {
              $_SESSION[error] = "There has been an unknown error during Form Table creation. Invalid Query = $query: Please contact support at ???? @ dbtechnosystems.com";
              mysql_close($db);
              header("Location: dbts_ABVFP_errorpage.php");
              exit;
              }
              //--- For debugging purposes only----
              //echo "Finished creating table ";
              //exit;
              // Check if the field exists in the table, to avoid crashes
              $result = mysql_list_fields($db_name, $dbts_table, $db);
              $fieldnumber = mysql_num_fields($result);
              for ($i = 0; $i < $fieldnumber; $i++) {
              $fieldstable[$i] = mysql_field_name($result, $i);
              }

              @$query = "INSERT INTO `$dbts_table`(";
              for ($i = 0; $i < (count($ndfieldname) - count($upload_Name)); $i++) {
              $dbfield = $ndfieldname[$i];
              //$dbvalue = $ndfieldvalue[$i];
              if (in_array($ndfieldname[$i],$fieldstable)) {
              @$query .= "`$ndfieldname[$i]` ,";
              }
              }
              @$query .= "`Submission_Date` ,";
              @$query .= "`IP_Address` ";
              @$query .= ")";

              @$query .= "VALUES (";
              for ($i = 0; $i < (count($ndfieldname) - count($upload_Name)); $i++) {
              if (in_array($ndfieldname[$i],$fieldstable)) {
              @$query .= "\"$ndfieldvalue[$i]\",";
              }
              }
              @$query .= "\"$Submission_Date\",";
              @$query .= "\"$ip\"";
              @$query .= ")" ;
              //echo $pfw_strQuery; Only for debugging
              $db = mysql_connect($db_host, $db_user, $db_password);
              if (!$db) {
              $_SESSION[error] = "There has been a connection problem:". mysql_error()."Please contact support at info @ dbtechnosystems.com";
              mysql_close($db);
              header("Location: dbts_ABVFP_errorpage.php");
              exit;
              }
              $db_selected = mysql_select_db($db_name, $db);
              if (!$db_selected) {
              $_SESSION[error] = "There has been a connection problem:". mysql_error().". Please contact support at ???? @ dbtechnosystems.com";
              mysql_close($db);
              header("Location: dbts_ABVFP_errorpage.php");
              exit;
              }
              //insert new record
              $result = mysql_query($query);
              if (!$result) {
              $_SESSION[error] = "There has been a connection problem:". mysql_error().". Please contact support at info @ dbtechnosystems.com";
              mysql_close($db);
              header("Location: dbts_ABVFP_errorpage.php");
              exit;
              }
              mysql_close($db);
              }

              // ------------Building the mail ----------------------

              // generate a random string to be used as the boundary marker
              $mime_boundary="==Multipart_Boundary_x".md5(mt_ran d())."x";
              // now we'll build the message headers
              $ndmailhead = "From: $ndemail\r\n" .
              "MIME-Version: 1.0\r\n" .
              "Content-Type: multipart/mixed;\r\n" .
              " boundary=\"{$mime_boundary}\"";

              for ($i = 0; $i < count($ndfieldname); $i++) {
              $ndmailbody .= "$ndfieldname_final[$i] = ".stripslashes($ndfieldvalue[$i])." \r\n";
              }
              $ndmailbody1 .= "$ndmailfirstline \r\n"
              . "$ndmailbody \r\n"
              . "$ndmaillastline \r\n"
              . "-----------------------------------------------------------\n"
              . "Date of submission : $date\r\n"
              . "Browser : $browser\r\n"
              . "IP address : $ip\r\n";

              $ndmailbody1 = "This is a multi-part message in MIME format.\n\n" .
              "--{$mime_boundary}\n" .
              "Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
              "Content-Transfer-Encoding: 7bit\n\n" .
              $ndmailbody1 . "\n\n";
              // now we'll process our uploaded files
              if (count($upload_Name)>0) {
              for ($i = 0; $i < count($upload_Name); $i++){
              // now we'll insert a boundary to indicate we're starting the attachment
              // we have to specify the content type, file name, and disposition as
              // an attachment, then add the file content.
              // NOTE: we don't set another boundary to indicate that the end of the
              // file has been reached here. we only want one boundary between each file
              // we'll add the final one after the loop finishes.

              $type = $upload_Type[$i];
              $name = $upload_Name[$i];
              $ndmailbody1 .= "--{$mime_boundary}\n" .
              "Content-Type: {$type};\n" .
              " name=\"{$name}\"\n" .
              "Content-Disposition: attachment;\n" .
              " filename=\"{$fileatt_name}\"\n" .
              "Content-Transfer-Encoding: base64\n\n" .
              $data[$i] . "\n\n";
              }
              }
              // here's our closing mime boundary that indicates the last of the message
              $ndmailbody1.="--{$mime_boundary}--\n";

              for ($i = 0; $i <= count($ndmailaddress1); $i++){
              mail($ndmailaddress1[$i], $ndmailsubject, $ndmailbody1, $ndmailhead);
              }
              if ($autoresponder == "Yes")
              {
              if ($ndincludeemail = "Yes") {
              $ndmfromaddress = $ndmailaddress2;
              }
              $ndmailbody = "";
              for ($i = 0; $i < (count($ndfieldname) - count($upload_Name)); $i++) {
              $ndmailbody .= "$ndfieldname_final[$i] = ".stripslashes($ndfieldvalue[$i])." \r\n";
              }
              if (count($upload_Name)>0) {
              $ndmailbody .= "You have also uploaded the following files: \r\n";
              for ($i = 0; $i < count($upload_Name); $i++){
              $k = $i +1;
              $ndmailbody .= "File $k : $upload_Name[$i] \r\n" ;
              }
              }
              $ndmailsubject = $autorespondersubject;
              $ndmailhead = "MIME-Version: 1.0\r\n";
              $ndmailhead .= "From: $autoresponderfrom < $ndmfromaddress >" . "\r\n";
              $ndmailbody1 = "$autoresponderfirstline\n"
              . "$ndmailbody\r\n"
              . "$autoresponderlastline\r\n"
              . "-----------------------------------------------------------\r\n"
              . "Time of submission : $date\r\n"
              . "-----------------------------------------------------------\r\n";
              mail($ndemail, $ndmailsubject, $ndmailbody1, $ndmailhead);
              }
              <?php
              // Request LoanExpress.co.za REST Web Service using
              // HTTP POST with curl. PHP4/PHP5
              // Allows retrieval of HTTP status code for error reporting
              // Modified: Johann du Toit, January 7, 2008
              // Original Author: Jason Levitt, February 1, 2006
              error_reporting(E_ALL);
              // The POST URL and parameters
              $request = 'http://rest.affiliateschool.co.za/financeleads/index.php';
              $affiliateid = '999'; // your affiliate id supplied by the affiliate school
              $secret = 'abcdefghijklmnopqrstuvwxyz'; // your secret to authorize submissions. Keep this secret!
              $postargs = 'affiliateid='.$affiliateid.'&secret='.$secret;
              $postargs .= '&loanamount='.urlencode($_POST['Loan_amount-R']); // The loan amount and type required
              $postargs .= '&credithistory='.urlencode($_POST['Credit_History-R']);
              $postargs .= '&loanpurpose='.urlencode($_POST['Loan_Purpose-R']);
              $postargs .= '&propertyowned='.urlencode($_POST['Value_of_Property-R']);
              $postargs .= '&bondholder='.urlencode($_POST['Bond_holder-R']);
              $postargs .= '&bondoutstanding='.urlencode($_POST['Bond_Outstanding-R']);
              $postargs .= '&title1='.urlencode($_POST['Title-R']);
              $postargs .= '&dobday1='.urlencode($_POST['Bday-R']);
              $postargs .= '&dobmonth1='.urlencode($_POST['Bmonth-R']); // Jan, Feb, Mar, etc... not numeric
              $postargs .= '&dobyear1='.urlencode($_POST['Byear-NR']); // full 4 digit year
              $postargs .= '&firstn1='.urlencode($_POST['First_Name-RA']);
              $postargs .= '&lastn1='.urlencode($_POST['Last_Name-RA']);
              $postargs .= '&maritalstatus='.urlencode($_POST['Maritual_Status-R']);
              $postargs .= '&dependants='.urlencode($_POST['Dependents-NR']);
              $postargs .= '&phone='.urlencode($_POST['Phone-NR']);
              $postargs .= '&email='.urlencode($_POST['Email-eR']);
              $postargs .= '&alternatephone='.urlencode($_POST['Alternate_phone-NR']);
              $postargs .= '&idnumber='.urlencode($_POST['ID_Number-NR']);
              $postargs .= '&occupation1='.urlencode($_POST['Occupation-RA']);
              $postargs .= '&employername1='.urlencode($_POST['Employer-RA']);
              $postargs .= '&grossincome1='.urlencode($_POST['Gross_Household_Income-NR']);
              $postargs .= '&grossincometype1='.urlencode($_POST['Maritual_Status-R']);
              $postargs .= '&joblength1='.urlencode($_POST['Time_at_work-R']);
              $postargs .= '&street='.urlencode($_POST['Adress-RA']);
              $postargs .= '&suburb='.urlencode($_POST['Suburb-A']);
              $postargs .= '&citytown='.urlencode($_POST['Town/City-AR']);
              $postargs .= '&code='.urlencode($_POST['Postal_code-NR']);
              $postargs .= '&timeataddress='.urlencode($_POST['Time_at_adress-R']);
              $postargs .= '&agreement='.urlencode($_POST['Products']); // Agree or Disagree

              // Get the curl session object
              $session = curl_init($request);
              // Set the POST options.
              curl_setopt ($session, CURLOPT_POST, true);
              curl_setopt ($session, CURLOPT_POSTFIELDS, $postargs);
              curl_setopt($session, CURLOPT_HEADER, true);
              curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
              // Do the POST and then close the session
              $response = curl_exec($session);
              curl_close($session);
              // Get HTTP Status code from the response
              $status_code = array();
              preg_match('/\d\d\d/', $response, $status_code);
              // Check for errors
              switch( $status_code[0] ) {
              case 201:
              // Success
              break;
              case 500:
              die('Your call failed and returned an HTTP status of 500. That means: Service unavailable. An internal problem prevented us from returning data to you.');
              break;
              case 401:
              die('Your call failed and returned an HTTP status of 401. That means: Forbidden. You do not have permission to access this resource, or are over your rate limit.');
              break;
              case 400:
              // You may want to fall through here and read the specific XML error
              die('Your call failed and returned an HTTP status of 400. That means: Bad request. The parameters passed to the service did not match as expected.');
              break;
              default:
              die('Your call returned an unexpected HTTP status of:' . $status_code[0]);
              }
              // Output
              echo $response;
              ?>
              if ($dbts_Formid == "1") {
              // Request LoanExpress.co.za REST Web Service using
              // HTTP POST with curl. PHP4/PHP5
              // Allows retrieval of HTTP status code for error reporting
              // Modified: Johann du Toit, January 7, 2008
              // Original Author: Jason Levitt, February 1, 2006

              error_reporting(E_ALL);

              // The POST URL and parameters
              $request = 'http://rest.affiliateschool.co.za/financeleads/index.php';
              $affiliateid = 'xxx'; // your affiliate id supplied by the affiliate school
              $secret = 'xxxxxxxxxxxxxxxxxxxxxxxxx'; // your secret to authorize submissions. Keep this secret!

              $postargs = 'affiliateid='.$affiliateid.'&secret='.$secret;

              $postargs .= '&loanamount='.urlencode("R8000-****00 Personal Loan"); // The loan amount and type required
              $postargs .= '&credithistory='.urlencode("clean");
              $postargs .= '&loanpurpose='.urlencode("Debt Consolidation");
              $postargs .= '&propertyowned='.urlencode("400000");
              $postargs .= '&bondholder='.urlencode("Standard Bank");
              $postargs .= '&bondoutstanding='.urlencode("100000");
              $postargs .= '&title1='.urlencode("Mr");
              $postargs .= '&dobday1='.urlencode("21");
              $postargs .= '&dobmonth1='.urlencode("Dec"); // Jan, Feb, Mar, etc... not numeric
              $postargs .= '&dobyear1='.urlencode("1971"); // full 4 digit year
              $postargs .= '&firstn1='.urlencode("Test");
              $postargs .= '&lastn1='.urlencode("Test Lead");
              $postargs .= '&maritalstatus='.urlencode("Married");
              $postargs .= '&dependants='.urlencode("2");
              $postargs .= '&phone='.urlencode("012 5431315");
              $postargs .= '&email='.urlencode("test@test.co.za");
              $postargs .= '&alternatephone='.urlencode("083 5551315");
              $postargs .= '&idnumber='.urlencode("7112215018123");
              $postargs .= '&occupation1='.urlencode("Computer Programmer");
              $postargs .= '&employername1='.urlencode("National Bank");
              $postargs .= '&grossincome1='.urlencode("100000");
              $postargs .= '&grossincometype1='.urlencode("Per Year");
              $postargs .= '&joblength1='.urlencode("10");
              $postargs .= '&street='.urlencode("72 Test Street");
              $postargs .= '&suburb='.urlencode("TestVille");
              $postargs .= '&citytown='.urlencode("Testerton");
              $postargs .= '&code='.urlencode("1000");
              $postargs .= '&timeataddress='.urlencode("25");
              $postargs .= '&agreement='.urlencode("Agree"); // Agree or Disagree


              // Get the curl session object
              $session = curl_init($request);

              // Set the POST options.
              curl_setopt ($session, CURLOPT_POST, true);
              curl_setopt ($session, CURLOPT_POSTFIELDS, $postargs);
              curl_setopt($session, CURLOPT_HEADER, true);
              curl_setopt($session, CURLOPT_RETURNTRANSFER, true);

              // Do the POST and then close the session
              $response = curl_exec($session);
              curl_close($session);

              // Get HTTP Status code from the response
              $status_code = array();
              preg_match('/\d\d\d/', $response, $status_code);

              // Check for errors
              switch( $status_code[0] ) {
              case 201:
              // Success
              break;
              case 500:
              $dbts_error = "Your call failed and returned an HTTP status of 500. That means: Service unavailable. An internal problem prevented us from returning data to you.";
              break;
              case 401:
              $dbts_error = "Your call failed and returned an HTTP status of 401. That means: Forbidden. You do not have permission to access this resource, or are over your rate limit.";
              break;
              case 400:
              // You may want to fall through here and read the specific XML error
              $dbts_error = "Your call failed and returned an HTTP status of 400. That means: Bad request. The parameters passed to the service did not match as expected.";
              break;
              default:
              $dbts_error = "Your call returned an unexpected HTTP status of:" . $status_code[0]);
              }
              if ($dbts_error != ""){
              $_SESSION[error] = $dbts_error ;
              header("Location: $errorpage.php");
              }
              }
              header("Location: $returnpage");
              ?>
              Don't miss the game for fear of striking out...

              Comment

              • mobilejack101
                Staff Sergeant

                • Oct 2007
                • 41

                #22
                Re: Need help with &quot;REST&quot; HTTP POST?

                OOPS! this is a double copy!

                Sorry my bad!

                Can someone delete this and the post above please?

                Sorry!
                Don't miss the game for fear of striking out...

                Comment

                • mobilejack101
                  Staff Sergeant

                  • Oct 2007
                  • 41

                  #23
                  Re: Need help with &quot;REST&quot; HTTP POST?

                  AAARG! I cant get the thing to work!

                  This is the error I get....after clicking on "submit"

                  Notice: Use of undefined constant error - assumed 'error' in /home/gcumjcjh/public_html/ABVFP/dbts_abvfp.php on line 765

                  Warning: Cannot modify header information - headers already sent by (output started at /home/gcumjcjh/public_html/ABVFP/dbts_abvfp.php:765) in /home/gcumjcjh/public_html/ABVFP/dbts_abvfp.php on line 766

                  Warning: Cannot modify header information - headers already sent by (output started at /home/gcumjcjh/public_html/ABVFP/dbts_abvfp.php:765) in /home/gcumjcjh/public_html/ABVFP/dbts_abvfp.php on line 769

                  I have downloaded ABVFP again and the script just to make sure my files are correct.

                  I then did exactly as you exsplained above...

                  This is how my code looks now...


                  <?php
                  # ----------------------------------------------------
                  # -----
                  # ----- This script was created by DB Technosystems.com
                  # -----
                  # ----- http://www.dbtechnosystems.com
                  # -----
                  # ----------------------------------------------------

                  error_reporting(55);
                  session_start();
                  //--- For debugging purposes only----
                  //echo "Opened file abvfp.php";
                  //exit;
                  //putenv("TZ=Europe/Rome"); // Change to whatever yout timezone is
                  require ("dbts_ABVFP_config.php");

                  //--- For debugging purposes only----
                  //echo "Opened config file abvfp.php";
                  //exit;
                  $dbts_Formid = $_POST['Formid'];
                  //--- For debugging purposes only----
                  //echo "dbts_Formid = testing $dbts_Formid testing";
                  //exit;
                  $dbts_Formurl1 = $_SERVER['HTTP_REFERER'];
                  //--- For debugging purposes only----
                  if ($dbts_Formid == "") {
                  $dbts_error = "I cannot process the form. The form has not been correctly setup. !";
                  $_SESSION[error] = $dbts_error ;
                  header("Location: dbts_ABVFP_errorpage.php");
                  }
                  $db = mysql_connect($db_host, $db_user, $db_password);
                  if ($db == FALSE){
                  $dbts_error = "Could not connect to the Database Server. Please check user details !";
                  $_SESSION[error] = $dbts_error ;
                  mysql_close($db);
                  header("Location: dbts_ABVFP_errorpage.php");
                  exit;
                  }
                  mysql_select_db($db_name, $db);
                  if (!mysql_select_db($db_name, $db)) {
                  $dbts_error = "Could not select Database. Please check user details !";
                  $_SESSION[error] = $dbts_error ;
                  mysql_close($db);
                  header("Location: dbts_ABVFP_errorpage.php");
                  }
                  $query = "SELECT Formid, Formname, Site, Formurl, Max_filesize, Uploadfolder, Emailaddress, EmailSubject, Emailheader, Emailfooter, Thankyoupage, Errorpage, Autoresponder, Include_email, Autoresponder_EmailSubject, Autoresponder_From, Autoresponder_Emailheader, Autoresponder_Emailfooter, Database_Store FROM ABVFP_Forms WHERE Formid= '$dbts_Formid'";
                  $result = mysql_query($query, $db);
                  $row = mysql_fetch_array($result, MYSQL_ASSOC);
                  if ($row =="") {
                  $dbts_error = "I cannot process the form. The form has not been correctly setup. !";
                  $_SESSION[error] = $dbts_error ;
                  mysql_close($db);
                  header("Location: dbts_ABVFP_errorpage.php");
                  }
                  //mysql_close($db);
                  //--- For debugging purposes only----
                  //echo "Finished connecting to the DB";
                  //exit;
                  // -------- RECEIVIMG CONFIGURATION VARIABLES FROM THE DB -----------

                  $ndsite = $row[Site] ;
                  $ndformurl = $row[Formurl] ;
                  $ndfilesize = $row[Max_filesize] ;
                  $ndmailsubject = $row[EmailSubject] ;
                  $ndmailfirstline = $row[Emailheader] ;
                  $ndmaillastline = $row[Emailfooter] ;
                  $autoresponderfirstline = $row[Autoresponder_Emailheader] ;
                  $autoresponderlastline = $row[Autoresponder_Emailfooter] ;
                  $autoresponder = $row[Autoresponder] ;
                  $autoresponderfrom = $row[Autoresponder_From] ;
                  $autorespondersubject = $row[Autoresponder_EmailSubject] ;
                  $nduploadfolder = $row[Uploadfolder] ;
                  $returnpage = $row[Thankyoupage] ;
                  $errorpage = $row[Errorpage] ;
                  $ndmailaddress = $row[Emailaddress] ;
                  $ndincludeemail = $row[Include_email] ;
                  $ndDatabase_Store = $row[Database_Store] ;
                  //Finding out if there are more than email addresses to receive the email

                  $ndmailaddress1 = explode(",", $ndmailaddress);
                  //Setting the autoresponder "From" email address
                  if (count($ndmailaddress1 ==0))
                  {
                  $ndmailaddress2 = $ndmailaddress;
                  }
                  if (count($ndmailaddress1 >=1)) {
                  $ndmailaddress2 = $ndmailaddress1[0];
                  }
                  if ($ndformurl1 != "") {
                  if ($ndformurl1 != $ndformurl) {
                  $nderror = "Illegal Form Submission \n";
                  }
                  }
                  //--- For debugging purposes only----
                  //echo "Finished field examining";
                  //exit;
                  // -------- RECEIVIMG FIELDNAMES VALUES AND VALIDATION DETAILS------

                  $internalfields = array ("submit", "reset", "Formid", "Submit", "SUBMIT", "RESET", "Reset");
                  $i = "0";
                  reset ($HTTP_POST_VARS);
                  while (list ($key, $val) = each ($HTTP_POST_VARS)) {
                  if (!in_array($key, $internalfields)) {
                  $fieldname = trim($key);
                  $fieldlenght = strlen(trim($key));
                  $realfieldlength = $fieldlenght;
                  if (substr($fieldname, -3, 1) == "-") {
                  $ndLast = substr($fieldname, -1, 1);
                  if ($ndLast == "R") {
                  $R[$i] = "R";
                  $V[$i] = substr($fieldname, -2, 1);
                  } else {
                  $V[$i] = substr($fieldname, -1, 1);
                  $R[$i] = substr($fieldname, -2, 1);
                  }
                  $realfieldlength = $fieldlenght-3;
                  }
                  if (substr($fieldname, -2, 1) == "-") {
                  $ndLast = substr($fieldname, -1, 1);
                  if ($ndLast == "R") {
                  $R[$i] = "R";
                  } else {
                  $V[$i] = substr($fieldname, -1, 1);
                  }
                  $realfieldlength = $fieldlenght-2;
                  }

                  // ------ Checking for miltiple Choice Values ---------
                  @$fieldvalue = $_POST[$key];
                  if (is_array($fieldvalue)) {
                  @$fieldvalue = @implode(", ",$_POST[$key]);
                  }
                  // ----Setting the clear Field Names and Values-------
                  $fieldname = substr($key, 0, $realfieldlength);
                  if ($fieldname == "Email")
                  {
                  $ndemail = $fieldvalue;
                  }
                  $ndfieldname[] = $fieldname;
                  $ndfieldname_final[] = str_replace("_", " ", $fieldname);
                  $ndfieldvalue[] = $fieldvalue;
                  $i = $i + 1 ;
                  }
                  }

                  //--- For debugging purposes only----
                  //echo "Finished field examining";
                  //exit;
                  // ------RECEIVING FILE VARIABLES--------------------

                  reset ($_FILES);
                  $i = 0;
                  while (list ($key, $val) = each ($_FILES)) {
                  if ($_FILES[$key]['name']!="") {
                  $upload_Name1 = ($_FILES[$key]['name']);
                  $upload_Name[] = str_replace(" ", "_", $upload_Name1);
                  $upload_Size[] = ($_FILES[$key]['size']);
                  $upload_Temp[] = ($_FILES[$key]['tmp_name']);
                  $upload_Type[] = ($_FILES[$key]['type']);
                  $uploadlink[] = "$nduploadfolder/$upload_Name[$i] \n";
                  $ndfieldname[] = $key;
                  $ndfieldname_final[] = str_replace("_", " ", $key);
                  $ndfieldvalue[] = $uploadlink[$i];
                  // if the upload succeded, the file will exist
                  if (file_exists($upload_Temp[$i])){
                  // check to make sure that it is an uploaded file and not a system file
                  if(is_uploaded_file($upload_Temp[$i])){
                  // open the file for a binary read
                  $file = fopen($upload_Temp[$i],'rb');
                  // read the file content into a variable
                  $data1 = fread($file,filesize($upload_Temp[$i]));
                  // close the file
                  fclose($file);
                  // now we encode it and split it into acceptable length lines
                  $data[] = chunk_split(base64_encode($data1));
                  }
                  $i = $i + 1;
                  }
                  }
                  }

                  function RecursiveMkdir($path)
                  {
                  if (!file_exists($path)) {
                  RecursiveMkdir(dirname($path));
                  mkdir($path, 0777);
                  }
                  }
                  //--- For debugging purposes only----
                  //echo "Finished uploading attached files ";
                  //exit;

                  // ------------VALIDATION OF THE FIELDS----------------
                  // ------------CHECKING FOR REQUIRED FIELDS----------
                  $i = 0;
                  for ($i = 0; $i < count($ndfieldname); $i++) {
                  if ($R[$i] == "R") {
                  if (strlen($ndfieldvalue[$i]) == 0) {
                  $nderror .= "The field $ndfieldname[$i] is missing !\n";
                  }
                  }

                  // ------------CHECKING FOR CORRECT EMAIL FIELDS----------

                  if ($V[$i] == "e") {
                  $fieldtype[$i] = "VARCHAR (100)" ;
                  if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $ndfieldvalue[$i])) {
                  $nderror .= "Your Email seems incorrect !\n";
                  }
                  if (substr_count($ndfieldvalue[$i] , '@') > 1) {
                  $nderror .= "The field $ndfieldname[$i] can only contain the @ character once !\n";
                  }
                  }
                  // ------------CHECKING FOR NUMERIC FIELDS----------

                  if ($V[$i] == "N") {
                  $fieldtype[$i] = "INT" ;
                  if ($ndfieldvalue[$i] != "") {
                  if (!is_numeric($ndfieldvalue[$i])) {
                  $nderror .= "The field $ndfieldname[$i] should be only numbers / No spaces allowed $nerror !\n";
                  }
                  }
                  }
                  // ------------CHECKING FOR FIELD SIZE UP TO 30 WITHOUT EMAIL ----------
                  if ($V[$i] == "A") {
                  $fieldtype[$i] = "VARCHAR (30)" ;
                  if (strlen($ndfieldvalue[$i]) >= 30) {
                  $nderror .= "The field $ndfieldname[$i] must be less than 30 characters !\n";
                  }
                  if (substr_count($ndfieldvalue[$i] , '@') > 0) {
                  $nderror .= "The field $ndfieldname[$i] cannot contain the @ character !\n";
                  }
                  }
                  // ------------CHECKING FOR FIELD SIZE UP TO 60 WITHOUT EMAIL ----------
                  if ($V[$i] == "B") {
                  $fieldtype[$i] = "VARCHAR (60)" ;
                  if (strlen($ndfieldvalue[$i]) >= 60) {
                  $nderror .= "The field $ndfieldname[$i] must be less than 60 characters !\n";
                  }
                  if (substr_count($ndfieldvalue[$i] , '@') > 0) {
                  $nderror .= "The field $ndfieldname[$i] cannot contain the @ character !\n";
                  }
                  }
                  // ------------CHECKING FOR FIELD SIZE UP TO 200 WITHOUT EMAIL ----------
                  if ($V[$i] == "C") {
                  $fieldtype[$i] = "VARCHAR (250)" ;
                  if (strlen($ndfieldvalue[$i]) >= 200) {
                  $nderror .= "The field $ndfieldname[$i] must be less than 200 characters !\n";
                  }
                  if (substr_count($ndfieldvalue[$i] , '@') > 0) {
                  $nderror .= "The field $ndfieldname[$i] cannot contain the @ character !\n";
                  }
                  }

                  // ------------CHECKING FOR FIELD SIZE UP TO 500 WITHOUT EMAIL ----------

                  if ($V[$i] == "D") {
                  $fieldtype[$i] = "MEDIUMTEXT" ;
                  if (strlen($ndfieldvalue[$i]) >= 500) {
                  $nderror .= "The field $ndfieldname[$i] must be less than 500 characters !\n";
                  }
                  if (substr_count($ndfieldvalue[$i] , '@') > 0) {
                  $nderror .= "The field $ndfieldname[$i] cannot contain the @ character !\n";
                  }
                  }
                  // ------------CHECKING FOR UNLIMITED FIELD SIZE WITHOUT EMAIL ----------
                  if ($V[$i] == "E") {
                  $fieldtype[$i] = "TEXT" ;
                  if (substr_count($ndfieldvalue[$i] , '@') > 0) {
                  $nderror .= "The field $ndfieldname[$i] cannot contain the @ character !\n";
                  }
                  }
                  // ------------CHECKING FOR FIELD SIZE UP TO 30 WITH ONE EMAIL ----------
                  if ($V[$i] == "F") {
                  $fieldtype[$i] = "VARCHAR (30)" ;
                  if (strlen($ndfieldvalue[$i]) >= 30) {
                  $nderror .= "The field $ndfieldname[$i] must be less than 30 characters !\n";
                  }
                  if (substr_count($ndfieldvalue[$i] , '@') > 1) {
                  $nderror .= "The field $ndfieldname[$i] can only contain the @ character once !\n";
                  }
                  }

                  // ------------CHECKING FOR FIELD SIZE UP TO 60 WITH ONE EMAIL ----------
                  if ($V[$i] == "G") {
                  $fieldtype[$i] = "VARCHAR (60)" ;
                  if (strlen($ndfieldvalue[$i]) >= 60) {
                  $nderror .= "The field $ndfieldname[$i] must be less than 60 characters !\n";
                  }
                  if (substr_count($ndfieldvalue[$i] , '@') > 1) {
                  $nderror .= "The field $ndfieldname[$i] can only contain the @ character once !\n";
                  }
                  }
                  // ------------CHECKING FOR FIELD SIZE UP TO 200 WITH ONE EMAIL ----------
                  if ($V[$i] == "H") {
                  $fieldtype[$i] = "VARCHAR (250)" ;
                  if (strlen($ndfieldvalue[$i]) >= 200) {
                  $nderror .= "The field $ndfieldname[$i] must be less than 200 characters !\n";
                  }
                  if (substr_count($ndfieldvalue[$i] , '@') > 1) {
                  $nderror .= "The field $ndfieldname[$i] can only contain the @ character once !\n";
                  }
                  }
                  // ------------CHECKING FOR FIELD SIZE UP TO 500 WITH ONE EMAIL ----------
                  if ($V[$i] == "J") {
                  $fieldtype[$i] = "TEXT" ;
                  if (strlen($ndfieldvalue[$i]) >= 500) {
                  $nderror .= "The field $ndfieldname[$i] must be less than 500 characters !\n";
                  }
                  if (substr_count($ndfieldvalue[$i] , '@') > 1) {
                  $nderror .= "The field $ndfieldname[$i] can only contain the @ character once !\n";
                  }
                  }
                  // ------------CHECKING FOR UNLIMITED FIELD SIZE WITH ONE EMAIL ----------
                  if ($V[$i] == "I") {
                  $fieldtype[$i] = "TEXT" ;
                  if (substr_count($ndfieldvalue[$i] , '@') > 1) {
                  $nderror .= "The field $ndfieldname[$i] can only contain the @ character once !\n";
                  }
                  }
                  if ($V[$i] == "") {
                  $fieldtype[$i] = "VARCHAR (250)";
                  }
                  }
                  // ------------CHECKING FOR MAX UPLOADED FILE SIZE ----------------------
                  $ndfilesize1= $ndfilesize*1024;
                  for ($i = 0; $i < count($upload_Name); $i++) {
                  if ($upload_Name[$i] != "" ) {
                  if ($upload_Size[$i] >= $ndfilesize1) {
                  $nderror .= "The size of $upload_Name[$i] is bigger than the allowed $ndfilesize Kb !\n";
                  }
                  }

                  }
                  if ($nderror != "") {
                  $_SESSION[error] = $nderror ;
                  header("Location: $errorpage");
                  exit;
                  }
                  //--- For debugging purposes only----
                  //echo "Finished validation of the fields ";
                  //exit;


                  //--------- Move the files to destination----------------
                  $nduploadfolder1 = basename($nduploadfolder);
                  for ($i = 0; $i < count($upload_Name); $i++) {
                  if ($upload_Size[$i] < $ndfilesize1 and $upload_Size[$i] >0)
                  {
                  $uploadFile = "$nduploadfolder1/".$upload_Name[$i];
                  if (!is_dir(dirname($uploadFile)))
                  {
                  @RecursiveMkdir(dirname($uploadFile));
                  }
                  else
                  {
                  @chmod(dirname($uploadFile), 0777);
                  }
                  @move_uploaded_file( $upload_Temp[$i] , $uploadFile);
                  chmod($uploadFile, 0644);
                  }
                  }
                  //--- For debugging purposes only----
                  //echo "Finished uploading files ";
                  //exit;
                  //------------- Find Server date and Time--------------------
                  $date = date("l jS F Y, g:i A");
                  $Submission_Date = date("F/d/Y");
                  //----------------- Find Browser and IPaddress --------------
                  $browser =$_SERVER['HTTP_USER_AGENT'];
                  $ip = $_SERVER['REMOTE_ADDR'];


                  // ---- STORING FIELD VALUES IN THE DATABASE TABLE ---------------
                  if ($ndDatabase_Store == "Yes") {
                  $dbts_table = "Form_Nr_$dbts_Formid";
                  // Check if the table exists already ------------

                  $result = mysql_list_tables($db_name);
                  while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
                  {
                  $key= "Tables_in_$db_name";
                  $tablename[] = $row[$key];
                  }
                  //--- For debugging purposes only----
                  //print_r($tablename);
                  //exit;
                  if (!in_array($dbts_table, $tablename)) {
                  $query = "CREATE TABLE `$dbts_table` (";
                  $query .='`Record_Nr` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, ';
                  for ($i = 0; $i < (count($ndfieldname) - count($upload_Name)); $i++) {
                  //$ndmailbody .= "$ndfieldname[$i] = $ndfieldvalue[$i] \r\n";
                  $query .= "`$ndfieldname[$i]` $fieldtype[$i], ";
                  }
                  $query .='`Submission_Date` VARCHAR (20),';
                  $query .='`IP_Address` VARCHAR (15)';
                  $query .=' )'
                  . ' ENGINE = myisam;';
                  }
                  //--- For debugging purposes only----
                  //echo "Query = $query****";
                  //exit;
                  if (mysql_query($query, $db)){
                  $message = "Installation completed";
                  }
                  else {
                  $_SESSION[error] = "There has been an unknown error during Form Table creation. Invalid Query = $query: Please contact support at .....................";
                  mysql_close($db);
                  header("Location: dbts_ABVFP_errorpage.php");
                  exit;
                  }
                  //--- For debugging purposes only----
                  //echo "Finished creating table ";
                  //exit;
                  // Check if the field exists in the table, to avoid crashes
                  $result = mysql_list_fields($db_name, $dbts_table, $db);
                  $fieldnumber = mysql_num_fields($result);
                  for ($i = 0; $i < $fieldnumber; $i++) {
                  $fieldstable[$i] = mysql_field_name($result, $i);
                  }

                  @$query = "INSERT INTO `$dbts_table`(";
                  for ($i = 0; $i < (count($ndfieldname) - count($upload_Name)); $i++) {
                  $dbfield = $ndfieldname[$i];
                  //$dbvalue = $ndfieldvalue[$i];
                  if (in_array($ndfieldname[$i],$fieldstable)) {
                  @$query .= "`$ndfieldname[$i]` ,";
                  }
                  }
                  @$query .= "`Submission_Date` ,";
                  @$query .= "`IP_Address` ";
                  @$query .= ")";

                  @$query .= "VALUES (";
                  for ($i = 0; $i < (count($ndfieldname) - count($upload_Name)); $i++) {
                  if (in_array($ndfieldname[$i],$fieldstable)) {
                  @$query .= "\"$ndfieldvalue[$i]\",";
                  }
                  }
                  @$query .= "\"$Submission_Date\",";
                  @$query .= "\"$ip\"";
                  @$query .= ")" ;
                  //echo $pfw_strQuery; Only for debugging
                  $db = mysql_connect($db_host, $db_user, $db_password);
                  if (!$db) {
                  $_SESSION[error] = "There has been a connection problem:". mysql_error()."Please contact support at .............................";
                  mysql_close($db);
                  header("Location: dbts_ABVFP_errorpage.php");
                  exit;
                  }
                  $db_selected = mysql_select_db($db_name, $db);
                  if (!$db_selected) {
                  $_SESSION[error] = "There has been a connection problem:". mysql_error().". Please contact support at .............................";
                  mysql_close($db);
                  header("Location: dbts_ABVFP_errorpage.php");
                  exit;
                  }
                  //insert new record
                  $result = mysql_query($query);
                  if (!$result) {
                  $_SESSION[error] = "There has been a connection problem:". mysql_error().". Please contact support at ....................................";
                  mysql_close($db);
                  header("Location: dbts_ABVFP_errorpage.php");
                  exit;
                  }
                  mysql_close($db);
                  }

                  // ------------Building the mail ----------------------

                  // generate a random string to be used as the boundary marker
                  $mime_boundary="==Multipart_Boundary_x".md5(mt_ran d())."x";
                  // now we'll build the message headers
                  $ndmailhead = "From: $ndemail\r\n" .
                  "MIME-Version: 1.0\r\n" .
                  "Content-Type: multipart/mixed;\r\n" .
                  " boundary=\"{$mime_boundary}\"";

                  for ($i = 0; $i < count($ndfieldname); $i++) {
                  $ndmailbody .= "$ndfieldname_final[$i] = ".stripslashes($ndfieldvalue[$i])." \r\n";
                  }
                  $ndmailbody1 .= "$ndmailfirstline \r\n"
                  . "$ndmailbody \r\n"
                  . "$ndmaillastline \r\n"
                  . "-----------------------------------------------------------\n"
                  . "Date of submission : $date\r\n"
                  . "Browser : $browser\r\n"
                  . "IP address : $ip\r\n";

                  $ndmailbody1 = "This is a multi-part message in MIME format.\n\n" .
                  "--{$mime_boundary}\n" .
                  "Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
                  "Content-Transfer-Encoding: 7bit\n\n" .
                  $ndmailbody1 . "\n\n";
                  // now we'll process our uploaded files
                  if (count($upload_Name)>0) {
                  for ($i = 0; $i < count($upload_Name); $i++){
                  // now we'll insert a boundary to indicate we're starting the attachment
                  // we have to specify the content type, file name, and disposition as
                  // an attachment, then add the file content.
                  // NOTE: we don't set another boundary to indicate that the end of the
                  // file has been reached here. we only want one boundary between each file
                  // we'll add the final one after the loop finishes.

                  $type = $upload_Type[$i];
                  $name = $upload_Name[$i];
                  $ndmailbody1 .= "--{$mime_boundary}\n" .
                  "Content-Type: {$type};\n" .
                  " name=\"{$name}\"\n" .
                  "Content-Disposition: attachment;\n" .
                  " filename=\"{$fileatt_name}\"\n" .
                  "Content-Transfer-Encoding: base64\n\n" .
                  $data[$i] . "\n\n";
                  }
                  }
                  // here's our closing mime boundary that indicates the last of the message
                  $ndmailbody1.="--{$mime_boundary}--\n";

                  for ($i = 0; $i <= count($ndmailaddress1); $i++){
                  mail($ndmailaddress1[$i], $ndmailsubject, $ndmailbody1, $ndmailhead);
                  }
                  if ($autoresponder == "Yes")
                  {
                  if ($ndincludeemail = "Yes") {
                  $ndmfromaddress = $ndmailaddress2;
                  }
                  $ndmailbody = "";
                  for ($i = 0; $i < (count($ndfieldname) - count($upload_Name)); $i++) {
                  $ndmailbody .= "$ndfieldname_final[$i] = ".stripslashes($ndfieldvalue[$i])." \r\n";
                  }
                  if (count($upload_Name)>0) {
                  $ndmailbody .= "You have also uploaded the following files: \r\n";
                  for ($i = 0; $i < count($upload_Name); $i++){
                  $k = $i +1;
                  $ndmailbody .= "File $k : $upload_Name[$i] \r\n" ;
                  }
                  }
                  $ndmailsubject = $autorespondersubject;
                  $ndmailhead = "MIME-Version: 1.0\r\n";
                  $ndmailhead .= "From: $autoresponderfrom < $ndmfromaddress >" . "\r\n";
                  $ndmailbody1 = "$autoresponderfirstline\n"
                  . "$ndmailbody\r\n"
                  . "$autoresponderlastline\r\n"
                  . "-----------------------------------------------------------\r\n"
                  . "Time of submission : $date\r\n"
                  . "-----------------------------------------------------------\r\n";
                  mail($ndemail, $ndmailsubject, $ndmailbody1, $ndmailhead);
                  }
                  if ($dbts_Formid == "1") {
                  // Request LoanExpress.co.za REST Web Service using
                  // HTTP POST with curl. PHP4/PHP5
                  // Allows retrieval of HTTP status code for error reporting
                  // Modified: Johann du Toit, January 7, 2008
                  // Original Author: Jason Levitt, February 1, 2006

                  error_reporting(E_ALL);

                  // The POST URL and parameters
                  $request = 'http://rest.affiliateschool.co.za/financeleads/index.php';
                  $affiliateid = 'xxx'; // your affiliate id supplied by the affiliate school
                  $secret = 'xxxxxxxxxxxxxxxxxxxxxxxxx'; // your secret to authorize submissions. Keep this secret!

                  $postargs = 'affiliateid='.$affiliateid.'&secret='.$secret;

                  $postargs .= '&loanamount='.urlencode($_POST['Loan_amount-R']); // The loan amount and type required
                  $postargs .= '&credithistory='.urlencode($_POST['Credit_History-R']);
                  $postargs .= '&loanpurpose='.urlencode($_POST['Loan_Purpose-R']);
                  $postargs .= '&propertyowned='.urlencode($_POST['Value_of_Property-R']);
                  $postargs .= '&bondholder='.urlencode($_POST['Bond_holder-R']);
                  $postargs .= '&bondoutstanding='.urlencode($_POST['Bond_Outstanding-R']);
                  $postargs .= '&title1='.urlencode($_POST['Title-R']);
                  $postargs .= '&dobday1='.urlencode($_POST['Bday-R']);
                  $postargs .= '&dobmonth1='.urlencode($_POST['Bmonth-R']); // Jan, Feb, Mar, etc... not numeric
                  $postargs .= '&dobyear1='.urlencode($_POST['Byear-NR']); // full 4 digit year
                  $postargs .= '&firstn1='.urlencode($_POST['First_Name-RA']);
                  $postargs .= '&lastn1='.urlencode($_POST['Last_Name-RA']);
                  $postargs .= '&maritalstatus='.urlencode($_POST['Maritual_Status-R']);
                  $postargs .= '&dependants='.urlencode($_POST['Dependents-NR']);
                  $postargs .= '&phone='.urlencode($_POST['Phone-NR']);
                  $postargs .= '&email='.urlencode($_POST['Email-eR']);
                  $postargs .= '&alternatephone='.urlencode($_POST['Alternate_phone-NR']);
                  $postargs .= '&idnumber='.urlencode($_POST['ID_Number-NR']);
                  $postargs .= '&occupation1='.urlencode($_POST['Occupation-RA']);
                  $postargs .= '&employername1='.urlencode($_POST['Employer-RA']);
                  $postargs .= '&grossincome1='.urlencode($_POST['Gross_Household_Income-NR']);
                  $postargs .= '&grossincometype1='.urlencode($_POST['Maritual_Status-R']);
                  $postargs .= '&joblength1='.urlencode($_POST['Time_at_work-R']);
                  $postargs .= '&street='.urlencode($_POST['Adress-RA']);
                  $postargs .= '&suburb='.urlencode($_POST['Suburb-A']);
                  $postargs .= '&citytown='.urlencode($_POST['Town/City-AR']);
                  $postargs .= '&code='.urlencode($_POST['Postal_code-NR']);
                  $postargs .= '&timeataddress='.urlencode($_POST['Time_at_adress-R']);
                  $postargs .= '&agreement='.urlencode($_POST['Products']); // Agree or Disagree

                  // Get the curl session object
                  $session = curl_init($request);

                  // Set the POST options.
                  curl_setopt ($session, CURLOPT_POST, true);
                  curl_setopt ($session, CURLOPT_POSTFIELDS, $postargs);
                  curl_setopt($session, CURLOPT_HEADER, true);
                  curl_setopt($session, CURLOPT_RETURNTRANSFER, true);

                  // Do the POST and then close the session
                  $response = curl_exec($session);
                  curl_close($session);

                  // Get HTTP Status code from the response
                  $status_code = array();
                  preg_match('/\d\d\d/', $response, $status_code);

                  // Check for errors
                  switch( $status_code[0] ) {
                  case 201:
                  // Success
                  break;
                  case 500:
                  $dbts_error = "Your call failed and returned an HTTP status of 500. That means: Service unavailable. An internal problem prevented us from returning data to you.";
                  break;
                  case 401:
                  $dbts_error = "Your call failed and returned an HTTP status of 401. That means: Forbidden. You do not have permission to access this resource, or are over your rate limit.";
                  break;
                  case 400:
                  // You may want to fall through here and read the specific XML error
                  $dbts_error = "Your call failed and returned an HTTP status of 400. That means: Bad request. The parameters passed to the service did not match as expected.";
                  break;
                  default:
                  $dbts_error = "Your call returned an unexpected HTTP status of:" . $status_code[0]);
                  }
                  if ($dbts_error != ""){
                  $_SESSION[error] = $dbts_error ;
                  header("Location: $errorpage.php");
                  }
                  }
                  header("Location: $returnpage");
                  ?>

                  I used notepad to edit the code...I dont know what I am doing wrong?

                  Please help!
                  Don't miss the game for fear of striking out...

                  Comment

                  • navaldesign
                    General & Forum Moderator

                    • Oct 2005
                    • 12080

                    #24
                    Re: Need help with &quot;REST&quot; HTTP POST?

                    There is nothing in line 37 of the ABVFP that would justify such an error message. So, most probably, you have somehow missed part of the code or you have added some code in the file that you have uploaded on the server.

                    If you wish, use my contact form to send me your login details and i will fix it for you.
                    Navaldesign
                    Logger Lite: Low Cost, Customizable, multifeatured Login script
                    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
                    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
                    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

                    Comment

                    • mobilejack101
                      Staff Sergeant

                      • Oct 2007
                      • 41

                      #25
                      Re: Need help with &quot;REST&quot; HTTP POST?

                      Naval I completed the your form and I would just like to mention that my
                      VALIDATE options on my edit and dropdown boxes dont work any more?

                      I am not sure if This happend after I pasted the HTML code on my loan amount drop list box.

                      I realy hope you can help me..

                      If You want to test the HTTP POST script just enter "test"in the NAME and LASTNAME fields.

                      Thanks alot for your help...I cant wait to launch my site and this script is giving me a big headache!

                      Thanks again

                      Jaco
                      Don't miss the game for fear of striking out...

                      Comment

                      • mobilejack101
                        Staff Sergeant

                        • Oct 2007
                        • 41

                        #26
                        Re: Need help with &quot;REST&quot; HTTP POST?

                        Hi Naval

                        I am in a panic at the moment..I am receiving leads! I don't know how and why? Can you please let me know if you can/did correct the problem?

                        Thank you in advance

                        Jaco
                        Don't miss the game for fear of striking out...

                        Comment

                        • navaldesign
                          General & Forum Moderator

                          • Oct 2005
                          • 12080

                          #27
                          Re: Need help with &quot;REST&quot; HTTP POST?

                          You have mail
                          Navaldesign
                          Logger Lite: Low Cost, Customizable, multifeatured Login script
                          Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
                          DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
                          Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

                          Comment

                          • mobilejack101
                            Staff Sergeant

                            • Oct 2007
                            • 41

                            #28
                            Re: Need help with &quot;REST&quot; HTTP POST?

                            Hi Naval

                            I did exactly as told and now get the following error:

                            Illegal Form Submission

                            and my validation options still dont work? What can I do to get my validation options to work again?

                            I will get back to George about the PHP code.

                            Thanks in advance

                            Jaco
                            Don't miss the game for fear of striking out...

                            Comment

                            Working...
                            X