简体   繁体   English

联系人表格未发送预定义的值

[英]Contact form doesn't send predefined values

I'm currently making a form wich works, but it doesn't send predefined values. 我目前正在制作一种可以正常工作的表单,但是它不发送预定义的值。 I have a few fields that I have predefined such as the user and total amount. 我有一些预定义的字段,例如用户和总数。 So it does send the values I enter, but not the ones that I have predefined Can someone please help me, so that this thing can work as it should? 因此,它确实会发送我输入的值,但不会发送我已预定义的值。有人可以请我帮忙,这样这件事就可以正常工作吗?

<?php require('includes/config.php'); 

//if not logged in redirect to login page
if(!$user->is_logged_in()){ header('Location: index.php'); } 
?>
<html>
    <head>
        <title>*****</title>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <!--[if lte IE 8]><script src="siteassets/assets/js/ie/hsiv.js"></script><![endif]-->
        <link rel="stylesheet" href="siteassets/assets/css/main.css" />
        <!--[if lte IE 8]><link rel="stylesheet" href="siteassets/assets/css/ie8.css" /><![endif]-->
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $('#next').keyup(calculate);
    $('#nextprice').keyup(calculate);
    $('#current').keyup(calculate);
    $('#currentprice').keyup(calculate);
});
function calculate(e)
{
    $('#total').val($('#next').val() * $('#nextprice').val() + $('#current').val() * $('#currentprice').val());
}
</script>

    </head>
    <body class="landing">
        <div id="page-wrapper">

            <!-- Header -->
                <header id="header" class="alt">

                    <nav id="nav">
                        <ul>
                            <li>
                                <a href="#" class="icon fa-angle-down">Menu</a>
                                <ul>
                                    <li><a href="home.php">Current Project</a></li>
                                    <li><a href="next.php">Next Projects</a></li>
                                    <li><a href="prev.php">Previous Projects</a></li>
                                    <li><a href="who.php">Who are we?</a></li>
                                </ul>
                            </li>
                            <li><a href="tickets.php" class="button">Tickets</a></li>
                            <li><a href='logout.php'>Logout</a></li>
                        </ul>
                    </nav>
                </header>

            <!-- Banner -->
                <section id="banner">
                    <h2>********</h2>
                    <p>*******</p>
                    <ul class="actions">
                        <li><a href="home.php" class="button">Current Project</a></li>
                        <li><a href="newproj.php" class="button">Next Projects</a></li>
                        <li><a href="prev.php" class="button">Previous Projects</a></li>
                        <li><a href="who.php" class="button">Who are we?</a></li>
                        <li><a href="tickets.php" class="button special">Tickets</a></li>
                    </ul>
                </section>

            <!-- Main -->




                <section id="main" class="container 75%">
                    <div class="box">
<? 
if($_SERVER['REQUEST_METHOD']=="POST")
{ 
if(strlen($_POST['name2']) == 0)
    { $error_msg ="- Please, provide us with your name.<br>"; } 

if(!empty($error_msg))
    { 
    //Field error 
    echo "<b>Your message can't be send due to the following reason:</b><br><br>"; 
    echo $error_msg; 
    echo "<br>Click on <a href='javascript:history.back(1)'>Go back</a> and provide us with your name.<br><br>"; 
    }
else 
    { 
    $recipient = "*********";  
    $subject = "******";  
    $header = "From: " . $_POST['uwemail'] . "\n"; 
    $mail_body = "Contact script werd op " . date("d-m-Y") . " om " . date("H:i") . " uur uitgevoerd.\n"; 
    $mail_body .= "De volgende persoon zou graag kaarten bestellen:\n\n"; 
    $mail_body .= "Naam: " . $_POST['name2'] . "\n"; 
    $mail_body .= "Met als kaartnummer: " . $_POST['card2'] . "\n"; 
    $mail_body .= "Aantal kaarten voor de lopende productie: " . $_POST['current2'] . "\n"; 
    $mail_body .= "Aantal kaarten voor de komende productie: " . $_POST['next2'] . "\n"; 
    $mail_body .= "Voor een totaal: " . $_POST['total2'] . "\n";            
    $mail_body .= "\n\n -- Einde van het contact bericht --"; 
    mail($recipient, $subject, $mail_body, $header); 
    print "<b>IMPORTANT!</b>";
    print "<br><br>Thank you for your reservation.";
    print "<br><br>Please note that this will be final upon receipt of payment of the total amount of";
    print " POST TOTAAL";
    print "EUR to Mazzini Theatre Productions";
    print "<br><br>Confirmation of reservation and payment instruction details will be sent to you via email.";
    print "<br><br>We are looking forward to meet you.";
    }
} 
else 
{ 
?>      
            <form action="<? echo $_SERVER['PHP_SELF']; ?>" method="POST" name="contact">
                            <div class="row uniform 50%">
                                <div class="6u 12u(mobilep)">
                                Your personal card number
                                    <input type="text" name="card2" id="card" value="<?php echo $_SESSION['username']; ?>" placeholder="Card Number" disabled/>
                                </div>
                                <div class="6u 12u(mobilep)">
                                Please enter your name. (mandatory)
                                    <input type="text" name="name2" id="name" value="" placeholder="Your name" />
                                </div>
                            </div>
                            <div class="row uniform 50%">
                                <div class="6u 12u(mobilep)">
                                Current Project - Smile
                                    <input type="text" name="current2" id="current" value="" placeholder="How many tickets would you like?" />
                                </div>
                                <div class="6u 12u(mobilep)">
                                Next Project - Sand
                                    <input type="text" name="next2" id="next" value="" placeholder="How many tickets would you like?" />
                                </div>
                            </div>
                            <div class="row uniform 50%">
                                <div class="6u 12u(mobilep)">
                                    <input type="hidden" id="currentprice" value="10" />
                                </div>
                                <div class="6u 12u(mobilep)">
                                    <input type="hidden" id="nextprice" value="10" placeholder="" />
                                </div>
                            </div>
                                            <div class="6u 12u(mobile)">
                                                <input name="uwemail" placeholder="Email" type="hidden" value="**THIS WORKS**"/>
                                            </div>
                            <div class="6u 12u(mobilep)">
                            Total price.(In EUR)
                                    <input type="text" name="total2" id="total" value=""  disabled/>
                                </div>
                            </div>

                            <div class="row uniform">
                                <div class="12u">
                                    <ul class="actions align-center">
                                        <li><input type="submit" name="submit"value="Place Order"/></li>
                                    </ul>
                                </div>
                            </div>
                        </form>


<?php 
} 
?> 

                    </div>
                </section>


            <!-- Footer -->
                <footer id="footer">

                    <ul class="copyright">
                        <li>© **DISCLAIMER**</li>
                    </ul>
                </footer>

        </div>

        <!-- Scripts -->
            <script src="siteassets/assets/js/jquery.min.js"></script>
            <script src="siteassets/assets/js/jquery.dropotron.min.js"></script>
            <script src="siteassets/assets/js/jquery.scrollgress.min.js"></script>
            <script src="siteassets/assets/js/skel.min.js"></script>
            <script src="siteassets/assets/js/util.js"></script>
            <!--[if lte IE 8]><script src="siteassets/assets/js/ie/respond.min.js"></script><![endif]-->
            <script src="siteassets/assets/js/main.js"></script>




    </body>
</html>

For your calculated fields you set attribute disabled . 对于您计算出的字段,将属性设置为disabled Fields with this attribute are not sent by form. 具有此属性的字段不是通过表单发送的。 Remove that attribute. 删除该属性。 You can set in that place readonly attribute 您可以在该位置设置readonly属性

Forms do not send disabled fields. 表单不会发送禁用的字段。 You alternatively can use readonly instead of disabled. 您也可以使用只读而不是禁用。

您的隐藏input缺少name=这就是为什么不发送它们的原因

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM