联系表单不会发送预定义的值

时间:2021-07-04 18:15:42

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>

3 个解决方案

#1


0  

For your calculated fields you set attribute disabled. Fields with this attribute are not sent by form. Remove that attribute. You can set in that place readonly attribute

对于计算字段,您可以设置属性已禁用。具有此属性的字段不会按表单发送。删除该属性。您可以在该位置设置readonly属性

#2


0  

Forms do not send disabled fields. You alternatively can use readonly instead of disabled.

表单不会发送禁用的字段。您也可以使用readonly而不是disabled。

#3


0  

your hidden inputs are missing name= that's why they are not sent

您隐藏的输入缺少名称=这就是他们不被发送的原因

#1


0  

For your calculated fields you set attribute disabled. Fields with this attribute are not sent by form. Remove that attribute. You can set in that place readonly attribute

对于计算字段,您可以设置属性已禁用。具有此属性的字段不会按表单发送。删除该属性。您可以在该位置设置readonly属性

#2


0  

Forms do not send disabled fields. You alternatively can use readonly instead of disabled.

表单不会发送禁用的字段。您也可以使用readonly而不是disabled。

#3


0  

your hidden inputs are missing name= that's why they are not sent

您隐藏的输入缺少名称=这就是他们不被发送的原因