J. DKYSR J. DKYSR - 1 year ago 96
PHP Question

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>

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download