0

Pretty new to PHP programming, but I am trying to merge two processes together. One of which I found the source code only the second with a working script I had on hand. In doing so I cant figure how to correct the issue. when posting to this php file from my form i get a Internal Server error 500 message.The goal is to collect the cart information and pars the data to an email. The original code defaulted to a paypal process, but my goal is to simulate a PO and not a purchase.

Ive played around with my original code and files and restructured the order of execution. I seem to think that the issue is around where the block of code starts under order details and before end of message but not sure what to do to fix this.

    <?php
/* Original Source ATN Simple Cart*/


if(isset($_REQUEST["proceed"]))
{
/***********************************************************************/
/*              Data Parsing Setup and Validation                      */
/***********************************************************************/
           //Loading the config.xml file
            if(file_exists("../config.xml"))
            {
                $config_file="../config.xml";
            }
            else
            if(file_exists("../atn-simple-cart/config.xml"))
            {
                $config_file="../atn-simple-cart/config.xml";
            }
            else
            {
                die("No config.xml file found");
            }


            //Initializing the config settings
            $xml_config = simplexml_load_file($config_file);

             // Declare HTML Form, Post Method Variables
            $yourname = check_input($_POST['yourname'], "Enter your name");
            $email    = check_input($_POST['email']);
            $location  = check_input($_POST['location']);
            $comments = check_input($_POST['comments'], "Write your comments");

            /* If e-mail is not valid show error message */
            if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
            {
                show_error("E-mail address not valid");
            }


/***********************************************************************/
/*                          Email Setup                                */
/***********************************************************************/


            /* Set e-mail recipient */
           $recipientemail  = "recipient@contact.com"; 



           // Always set content-type when sending HTML email
           $headers = "MIME-Version: 1.0" . "\r\n";
           $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
           $headers = "From: shop@company.com" . "\r\n" ;


            /* Let's prepare the message for the e-mail */
            $message = "Hello!

            A new form request has been submitted by:

            Name: $yourname
            E-mail: $email

            Comments:
            $comments

            Order Details:
              "Ordered items: " . stripslashes($_REQUEST["products_list"])."\n\n".
              "Total value: ".$xml_config->configuration->currency_symbol.$_REQUEST["products_value"]

            End of message
            ";



            /* Send the message using mail() function */
            mail($recipientemail, "Shop Order: " . $yourname . "(" . $location . ")", $message, $headers);

            /* Redirect visitor to the thank you page */
            header('Location: thanks.htm');
            exit();


?>
    <script>
    parent.document.location.href="<?php echo $paypal_link;?>";
    </script>
<?php
}
?>

Any help figuring out what is causing the issue or how to correct it would be appreciated.

smartinez
  • 1
  • 1
  • Note: Unless you're running an ancient version of PHP that has "magic quotes" `stripslashes` will only destroy data. Don't use it. – tadman Jul 17 '19 at 18:47
  • `Line : 70 -- syntax error, unexpected 'Ordered' (T_STRING)` – j08691 Jul 17 '19 at 18:52
  • 1
    For starters, turn on error reporting: https://stackoverflow.com/q/1053424/296555. How are you calling this script? – waterloomatt Jul 17 '19 at 19:00

0 Answers0