i have the following form in html:
<form id="signguestbook" class="form-horizontal" action="upload.php" method="post" enctype="multipart/form-data">
<div class="control-group">
<label class="control-label" for="inputName">Uw naam</label>
<div class="controls"><input type="text" id="inputName" placeholder="Uw naam"></div>
</div>
<div class="control-group">
<label class="control-label" for="inputEmail">Email</label>
<div class="controls"><input type="text" id="inputEmail" placeholder="Email"><span class="maildisclaimer">(uw e-mailadres zal niet op onze site verschijnen)</span></div>
</div>
<div class="control-group">
<label class="control-label" for="inputText">Uw ervaring:</label>
<div class="controls"><textarea rows="5" cols="50" id="inputText" placeholder="Geef hier mee hoe u uw verblijf ervaren heeft!"></textarea></div>
</div>
<div class="control-group">
<label class="control-label" for="inputPhoto">Foto:</label>
<div class="controls"><input type="file" name="photo" id="photo" /></div>
</div>
<div class="control-group">
<div class="controls"><input type="submit" class="btn" value="Versturen" /></div>
</div>
</form>
With twitter bootstrap it looks OK with that lay-out.
Then I have a upload.php with following test code:
<?php
if ($_POST["inputName"]) {
echo "Naam: " . $_POST["inputName"] . "<br />";
}
if ($_POST["inputEmail"]) {
echo "Mail: " . $_POST["inputEmail"] . "<br />";
}
if ($_POST["inputText"]) {
echo "Text: " . $_POST["inputText"] . "<br />";
}
// photo is the name of our file input field
if ($_FILES['photo']['error'] > 0) {
echo "Error: " . $_FILES['photo']['error'] . "<br />";
} else {
echo "File name: " . $_FILES['photo']['name'] . "<br />";
echo "File type: " . $_FILES['photo']['type'] . "<br />";
echo "File size: " . ($_FILES['photo']['size'] / 1024) . " Kb<br />";
echo "Temp path: " . $_FILES['photo']['tmp_name'];
}
?>
I didn't expect any errors here but I get the following:
Notice: Undefined index: inputName in /var/www/greze/upload.php on line 3
Notice: Undefined index: inputEmail in /var/www/greze/upload.php on line 6
Notice: Undefined index: inputText in /var/www/greze/upload.php on line 9
File name: 3479331713.pdf
File type: application/pdf
File size: 230.8388671875 Kb
Temp path: /tmp/phpJ4z0FV
My file gets recognized, but no $_POST variables. When I do var_dump($_POST) its an empty array. So it should be something in my form, but I've set it to post and the enctype is correct (as I recall)....
I must admit that my coding is off and it's been a while.
Thanks in advance!!
if (isset($_POST["inputName"])) {filefield is named. Change<input type="text" id="inputName" placeholder="Uw naam">to<input type="text" id="inputName" name="inputName" placeholder="Uw naam">and do the same for the rest.nameof the input element, not theid, to be passed to the server on submit.$inputName=$_POST['inputName'];and do the same for the rest.