简单表单不会获得$ _POST值并且无法提交

时间:2014-08-19 00:37:05

标签: php html forms post

不知何故,这需要我一天但仍然没有解决,我有其他形式正常工作。但是这个看起来很完美,但它只是在我提交表单后刷新页面。

 <form action="" enctype='multipart/form-data' name= 'myForm' id="myForm" method='post'>


<label>
<span>Product Name</span><input id="product_name" value='<?php echo $product_name;?>'     type="text" name="product_name"  disabled >
</label>

<label>
<span>Retail Price</span> <input name='retail_price' value="<?php echo $retail_price;?>"  type='text' id='retail_price' size='10' disabled >
</label>

<label>
<span>Discount (%)</span> <input name='discount' value="<?php echo $discount;?>" type='text' id='discount' size='10'disabled  >
</label>
<label>
<span>Details</span><textarea id="details" class="product_details" placeholder="For any other reasons, please provide details here" name="details"></textarea>
</label>

<label>
<span>Reason to Report</span>
<select name='reason' id='reason' class="required">
<option value = '' > </option>
<option value = 'price10' > Product price is higher than $9.9</option>
<option value = 'shelf' > Product is off the shelf</option>
<option value = 'no_fs' > Product does not have free-shipping</option>
<option value = 'reject' > Seller does not deliver products</option>
<option value = 'price_not_match' > Product Price does not match on Upto9 </option>
<option value = 'category' > Product is in wrong category </option>
<option value = 'other' > Other reasons</option>
</label>

<label>
<input name='submit' type='submit' id='button' class="button" value="Submit Report"/>
</label>

</form>

这是我的PHP代码:

echo 'before';
if (isset($_POST['submit'])) { 
echo 'after';
var_dump($_POST); 
$con= mysqli_connect("xxxxx.com"," admin","xxxxx","xxxxx") or die(mysqli_error($con));
$details=mysqli_real_escape_string($con,$_POST['details']);
$reason=mysqli_real_escape_string($con,$_POST['reason']);
$ip = preg_replace('#[^0-9.]#', '', getenv('REMOTE_ADDR'));
$sql="INSERT INTO reports (pid,product_name,listing_price,links,discount,retail_price,details,stock_level,reason,report_time,reporter,reporter,ip) VALUES 
                    ('$pid','$product_name','$listing_price','$links','$discount','$retail_price','$details','$stock_level','$reason',now(),'$log_username','$ip')";
$query = mysqli_query($con, $sql);                      
mysqli_insert_id($con); 
mysqli_close($con);
header('Location: ' . $_SERVER['HTTP_REFERER']);
echo "successful!";} 

输出是:befre 我添加了sql代码之后var_dump($ _ POST)什么都没给我,所以可能sql代码错了......

0 个答案:

没有答案