我有以下模型来收集数据。
<form class="form-login" name="myform" action="transactionsave.php" method="post">
<div class="modal fade" id="transaction" role="dialog" >
<div class="modal-dialog modal-sm">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">New Transaction</h4>
</div>
<div class="modal-body">
Select Date
<div class="form-group">
<input type="text" id="datepicker1" name="datepicker1" class="form-control clsDatePicker"
placeholder="<?php echo date('Y-m-d')?>" type="text" value="<?php echo date('Y-m-d')?>" required>
</div>
<div class="form-group">
Income/ Expenses
<select class="form-control" size="1" name="maincat" onChange="setOptions(document.myform.maincat.options[document.myform.maincat.selectedIndex].value);">
<optgroup label="Income">
<option value="Income" selected="selected">Income</option>
</optgroup>
<optgroup label="Expenses">
<option value="Bank charges">Bank charges</option>
<option value="Bills">Bills</option>
<option value="Clothing">Clothing</option>
<option value="Donations">Donations</option>
<option value="Education">Education</option>
<option value="Electronic">Electronics</option>
<option value="Food">Food</option>
<option value="Health care">Health care</option>
</optgroup>
</select>
</br>
</div>
Amount
<input type="text" class="form-control" placeholder="Amount" onKeyPress="return isNumberKey(event)" maxlength="12" required ></input>
</br>
</div>
<div class="modal-footer">
<button data-dismiss="modal" class="btn btn-info" type="button">Cancel</button>
<input type="submit" class="btn btn-success" value="Submit" />
</div>
</div>
</div>
</form>
</div>
我需要将相关数据传递到名为transactionsave.php的php文件中。当我按下提交按钮时,它会指向transactionsave.php并给出以下错误页面。
注意:未定义索引:在线上输入C:\ wamp \ www \ OFMS \ dash_board \ transactionsave.php ..
注意:未定义索引:C:\ wamp \ www \ OFMS \ dash_board \ transactionsave.php中的SelectedDate ..
依旧......
和我的transactionsave.php代码如下..
<?php
$type=$_POST['type'];
$SelectedDate=$_POST['SelectedDate'];
$amount=$_POST['amount'];
$payee=$_POST['payee'];
$maincat=$_POST['maincat'];
$subcat=$_POST['subcat'];
$comments=$_POST['comments'];
session_start();
$session=$_SESSION['user'];
$con=mysqli_connect("localhost","root","123","wfms");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
echo "$type"."</br>";
echo "$SelectedDate"."</br>";
echo "$amount"."</br>";
echo "$payee"."</br>";
echo "$maincat"."</br>";
echo "$subcat"."</br>";
echo "$comments"."</br>";
mysqli_close($con);
?>
因为我是新手,请告诉我如何将相关数据从modal传递给php ..
答案 0 :(得分:0)
使用html输入和php $_POST['InputsName'];
$_POST['InputsName'];
的值为:<input type="text" name="InputsName" placeholder="My Input"/>
$_POST['InputsName'];
将来自该输入。