PHP týden PHP týden
Tento týden až 80% sleva na e-learning PHP!
Avatar
Patrik Schiller:17. března 14:58

Odesílání na email

<?php
$namebusiness = $_POST['namebusiness'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$adress = $_POST['adress'];
$city = $_POST['city'];
$psc = $_POST['psc'];
$state = $_POST['state'];
$phone = $_POST['phone'];
$visitor_email = $_POST['email'];
$data = $_POST['data'];


$email_subject = "Order";

$message = "
<html>
<head>
<title>Your order</title>
</head>
<body>
<table>
<tr>
<th>Name Of Business:</th>
<td>$namebusiness</td>
</tr>
<tr>
<th>First name</th>
<td>$firstname</td>
</tr>
<tr>
<th>Last name:</th>
<td>$lastname</td>
</tr>
<tr>
<th>E-mail:</th>
<td>$visitor_email</td>
</tr>
<tr>
<th>Adress:</th>
<td>$adress</td>
</tr>
<tr>
<th>City:</th>
<td>$city</td>
</tr>
<tr>
<th>Post Code / ZIP:</th>
<td>$psc</td>
</tr>
<tr>
<th>State:</th>
<td>$state</td>
</tr>
<tr>
<th>Phone number:</th>
<td>$phone</td>
</tr>

                <tr>
            <th >Product Name</th>
            <th >Quantity</th>
            <th >Price</th>
            <th >Total</th>

        </tr>
</table>
</body>
</html>

";






$to = "$visitor_email, [email protected]";
$headers = 'From: [email protected]' . "\r\n" .
    'Content-type: text/html; charset=UTF-8' . "\r\n".
    'X-Mailer: PHP/' . phpversion();

mail($to,$email_subject,$message,$headers);
header("Content-type: text/html; charset=UTF-8");
header("Location: thanks.html");



?>

Data objednávky

<link rel="stylesheet" href="css/bootstrap.min.css" />
                 <title>Czech House ITD</title>
                <script src="js/bootstrap.min.js"></script>
                <style>
                .popover
                {
                    width: 100%;
                    max-width: 800px;
                }
                </style>
        </head>
        <body>
<header>
   <div id="radius" class="main-heading">Czech House Itd</div>
    <div class="main-heading1">Wholesale only</div>

  </header>
  <div class="title">Toys</div>
                <div class="container">
                        <br />

                        <br />
                        <nav class="navbar navbar-default" role="navigation">
                                <div class="container-fluid">
                                        <div class="navbar-header">
                                                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
                                                <span class="sr-only">Menu</span>
                                                <span class="glyphicon glyphicon-menu-hamburger"></span>
                                                </button>
                                                <a class="navbar-brand" href="/">Webslesson</a>
                                        </div>

                                        <div id="navbar-cart" class="navbar-collapse collapse">
                                                <ul class="nav navbar-nav">
                                                        <li>
                                                                <a id="cart-popover" class="btn" data-placement="bottom" title="Shopping Cart">
                                                                        <span class="glyphicon glyphicon-shopping-cart"></span>
                                                                        <span class="badge"></span>
                                                                        <span class="total_price"0.00</span>

                                                                </a>
                                                        </li>
                                                </ul>
                                        </div>

                                </div>
                        </nav>


                        <form id="concact-form" method ="post" action="concact-form.php">
                        <div id="popover_content_wrapper" style="display: none">
                                <span id="cart_details"></span>
                                <div align="right">

                                        <a href="concact.php" class="btn btn-primary" id="check_out_cart">
                                        <span class="but"></span>Send
                                        </a>
                                        <a href="#" class="btn btn-default" id="clear_cart">
                                        <span class="glyphicon glyphicon-trash"></span> Clear
                                        </a>
                                </div>
                        </div>
                </form>
                        <div id="display_item">


                        </div>

                </div>
                <br />
                <div class="footer1">
  <h7 class="footer2">Copyright © 2018 Patrik Schiller </h7>

</div>
        </body>
</html>

<script>
$(document).ready(function(){

        load_product();

        load_cart_data();

        function load_product()
        {
                $.ajax({
                        url:"fetch_itemtoys.php",
                        type:"POST",
                        success:function(data)
                        {
                                $('#display_item').html(data);
                        }
                });
        }

        function load_cart_data()
        {

                $.ajax({
                        url:"fetch_carttoys.php",
                        method:"POST",
                        dataType:"json",
                        success:function(data)
                        {
                                $('#cart_details').html(data.cart_details);
                                $('.total_price').text(data.total_price);
                                $('.badge').text(data.total_item);
                        }
                });
        }

        $('#cart-popover').popover({
                html : true,
        container: 'body',
        content:function(){
                return $('#popover_content_wrapper').html();
        }
        });

        $(document).on('click', '.add_to_cart', function(){
                var product_id = $(this).attr("id");
                var product_name = $('#name'+product_id+'').val();
                var product_price = $('#price'+product_id+'').val();
                var product_quantity = $('#quantity'+product_id).val();
                var action = "add";
                if(product_quantity > 0)
                {
                        $.ajax({
                                url:"actiontoys.php",
                                method:"POST",
                                data:{product_id:product_id, product_name:product_name, product_price:product_price, product_quantity:product_quantity, action:action},
                                success:function(data)
                                {
                                        load_cart_data();
                                        alert("Item has been Added into Cart");
                                }
                        });
                }
                else
                {
                        alert("lease Enter Number of Quantity");
                }
        });

        $(document).on('click', '.delete', function(){
                var product_id = $(this).attr("id");
                var action = 'remove';
                if(confirm("Are you sure you want to remove this product?"))
                {
                        $.ajax({
                                url:"actiontoys.php",
                                method:"POST",
                                data:{product_id:product_id, action:action},
                                success:function()
                                {
                                        load_cart_data();
                                        $('#cart-popover').popover('hide');
                                        alert("Item has been removed from Cart");
                                }
                        })
                }
                else
                {
                        return false;
                }
        });

        $(document).on('click', '#clear_cart', function(){
                var action = 'empty';
                $.ajax({
                        url:"actiontoys.php",
                        method:"POST",
                        data:{action:action},
                        success:function()
                        {
                                load_cart_data();
                                $('#cart-popover').popover('hide');
                                alert("Your Cart has been clear");
                        }
                });
        });





});

</script>

Zkusil jsem: Zkoušel jsem to různě poupravovat ale nešlo mi to.

Chci docílit: Chci odeslat nákupní košík na email

 
Odpovědět 17. března 14:58
Avatar
Peter Mlich
Člen
Avatar
Peter Mlich:18. března 7:44

A jakou to pise chybu? A jak jsi chybu hledal? Zkousel jsi echo na ruznych radcich a zakomentovat to header() presmerovani? A co presne nefunguje? A kdyz si udelas jednoduchy kod na posilani mailu, tak funguje?

$from = '[email protected]';
$to = '[email protected]';
$subject = 'test php mail';
$message = 'test zprava';
        // ??? RFC 821, RFC 2821, rfc1341
        $headers   = array();
        $headers[] = "From: $from";
        $headers[] = "Reply-To: $from";
        $headers[] = "Return-To: $from";
//      if ($form['notify']==true)
//              {
//              $headers[] = "Disposition-Notification-To: $from";
//              $headers[] = "Return-Receipt-To: $from";
//              }
        $headers[] = 'MIME-Version: 1.0';
        $headers[] = 'X-Mailer: PHP/' . phpversion();
//      $headers[] = 'Content-Type: multipart/mixed; boundary="' . $uid . '"';
//      $headers[] = 'This is a multi-part message in MIME format.';
        $headers   = implode(PHP_EOL, $headers);
//      $from      = "=?utf-8?B?".base64_encode($from)   ."?=";
//      $to        = "=?utf-8?B?".base64_encode($to)     ."?=";
//      $subject   = "=?utf-8?B?".base64_encode($subject)."?=";
        return mail($to, $subject, $message, $headers);

A mimochodem, asi mas spatne odkaz

<a href="concact.php"
 
Nahoru Odpovědět 18. března 7:44
Děláme co je v našich silách, aby byly zdejší diskuze co nejkvalitnější. Proto do nich také mohou přispívat pouze registrovaní členové. Pro zapojení do diskuze se přihlas. Pokud ještě nemáš účet, zaregistruj se, je to zdarma.

Zobrazeno 2 zpráv z 2.