邮政编码元素字段错误 - PHP / HTML

时间:2014-10-06 12:52:38

标签: php html

我遇到这个简单的代码有点麻烦,我肯定错过了一些小东西,但我试图修复它无济于事, 由于某种原因,除了'postcode'字段之外,所有其他字段都正确填写。这是HTML:

div class="form-field float-left">
            <div class="input text"><label for="fname">First Name</label>
            <input name="fname" value="" maxlength="150" type="text" id="fname"/>          
</div>      
</div>


<div class="form-field float-left">
         <div class="input text"><label for="postcode">Postcode</label>
         <input name="postcode" value="" maxlength="12" type="text" id="postcode"/>    
</div>  
</div>

这是PHP:

$fname = $_POST['fname'];
$postcode = $_POST['postcode'];

#This works ok and adds the value to the element
#
$fnameElement = $xmldoc->createElement('fname');
$record->appendChild($fnameElement);
$fnameText = $xmldoc->createTextNode($fname);
$fnameElement->appendChild($fnameText);

#But this part does not seem to work, adds the element but not the values from the $_POST['postcode']
#
$postcodeElement = $xmldoc->createElement('postcode');
$record->appendChild($postcodeElement);
$postcodeText = $xmldoc->createTextNode($postcode);
$postcodeElement->appendChild($postcodeText);

我看不出我错过了什么,任何帮助都会受到赞赏。

干杯

0 个答案:

没有答案