Вопрос

I need to put some predefined text into the hidden field in contact form and than send it to mail. But its not showing in mail. Any help? My form code is this:

<?php 
require('assets/dbconn.php');
$result = mysqli_query($con,"SELECT * FROM auctions WHERE id=$id");
$row = mysqli_fetch_array($result);
?>
<form  class="form" id="contactForm" method="post" enctype="multipart/form-data"  action='action.php'>
<label for="email" class="label_text">E-mail:<span class="required_sign">*</span></label>
<input id="email" name="email" class="required" type="email" />
<input type="hidden" name="code" value="<?php echo $row['CodeFromDB']; ?>" />
<button type="submit">SEND</button>
</form>
Это было полезно?

Решение

You need to set the value attribute of the input MDN Input Reference

<input id="code" name="code" type="hidden" value="<?php echo $row['CodeFromDB']; ?>"/>

Also, verify that $row['CodeFromDB'] is not empty, either by echoing it, or using testing with php's empty() function.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top