所以我已经坚持了大约一天,想想也许stackoverflow可能会有所帮助。
我在该表单中有一个表格,有一个表格,在该表格中,每一行(1-2)都有需要在同一页面上发布的表格。到目前为止,我已经使用了NiceHash表单,尽管MPH的帖子似乎无论如何都无法正常工作。到目前为止我试图做的事How to place two forms on the same page?& 2 forms on same page php
我注意到的是,他们发布到不同页面的那些帖子中,我将数据发布在同一页面上。
<form method="POST" action="">
<table class="table table-striped" style="width: auto;" id="api-table">
<tr>
<th style="width: 10px">ID</th>
<th>Name</th>
<th style="width: 15%;">BTC ADDR</th>
<th style="width: 30%;">API ID</th>
<th style="width: 22%;">API KEY</th>
<th style="width: 40px">Status</th>
</tr>
<tr>
<td>1.</td>
<td>nicehash
<?php echo $userRow2[0]['company_name'];?>
</td>
<td>btc addy
<p>
<?php echo $userRow['user_btc'];?>
</p>
</td>
<th>
<form method="POST" action="">
<p><input required="yes" type="text" name="nicehash_api_id" value="<?php echo $userRow['nicehash_api_id'];?>" placeholder="<?php if ($userRow['nicehash_api_id'] == NULL) { echo ' Enter NiceHash API ID';} ?>" style="width: 50%;" /></p>
</th>
<th>
<div>
<p><input type="text" required="yes" name="nicehash_api_key" value="<?php echo $userRow['nicehash_api_key'];?>" placeholder="<?php if ($userRow['nicehash_api_key'] == NULL) { echo ' Enter NiceHash API Key';} ?>" style="width: 100%;" /></p>
</div>
</form>
</th>
<td>
<center>
<?php
if ($userRow['nicehash_api_id'] !== NULL && $userRow['nicehash_api_key'] !== NULL)
{
echo '<span class="label label-success">Active</span>';
}
elseif ($userRow['nicehash_api_id'] == NULL && $userRow['nicehash_api_key'] == NULL)
{
echo '<span class="label label-danger">Disabled</span>';
}
?>
</center>
</td>
</tr>
<tr>
<td>2.</td>
<td>miningpoolhub
<?php echo $userRow2[1]['company_name'];?>
</td>
<td>
<p> btc addy
<?php echo $userRow['user_btc'];?>
</p>
</td>
<th>NULL</th>
<th>
<form method="POST" action="">
<p><input required="yes" type="text" name="mph_api_key" value="<?php echo $userRow['mph_api_key'];?>" name="mph_api_key" placeholder="<?php if ($userRow['mph_api_key'] == NULL) { echo ' Enter MiningPoolHub API Key';} ?>" style="width: 100%;" /></p>
</form>
</th>
<td>
<center><span class="label label-danger">Disabled</span></center>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td><button type="submit" name="mph-api-btn" class="btn">Update MiningPoolHub API</button></td>
<td><button type="submit" name="nh-api-btn" class="btn">Update NiceHash API</button></td>
</tr>
</table>
</form>
以下是发布的代码
<?php
if (isset($_POST['nh-api-btn']))
{
$uid = $userRow['user_id'];
$api_id = strip_tags($_POST['nicehash_api_id']);
$api_key = strip_tags($_POST['nicehash_api_key']);
if ($userRow['nicehash_api_id'] == $api_id && $userRow['nicehash_api_key'] == $api_key)
{
$error = 'Error: NiceHash API ID & KEY already exists.';
}
else
{
$idkey_check = @file_get_contents(utf8_encode('https://api.nicehash.com/api?method=balance&id='.$api_id.'&key='.$api_key));
if ($idkey_check == NULL)
{
$file_get_error = 'Network Error: oh Snap, we will be back shortly.';
}
$result = json_decode($idkey_check, true);
if (isset($result['result']['error']) == 'Incorrect key.') {
$ncheck_error = 'Invalid API ID or KEY.';
}
elseif (isset($result['result']['pending_balance']) !== NULL)
{
if ($auth_user->update_nh_api_data($uid,$api_id,$api_key))
{
$success = 'Success: NiceHash API ID & KEY Updated';
echo "<script>$('#api-table').load(document.URL + ' #api-table');</script>";
}
}
}
//:::::::::
if (isset($_POST['mph-api-btn']))
{
$mph_key = $_POST['mph_api_key'];
if ($userRow['mph_api_key'] == $mph_key)
{
$mph_error = 'Error: API KEY Exists Already.';
}
elseif ($userRow['mph_api_key'] == NULL)
{
$key_check = @file_get_contents(utf8_encode('https://miningpoolhub.com/index.php?page=api&action=getuserallbalances&api_key='.$mph_key));
$encode = json_encode($key_check);
$decode = json_decode($e, true);
if ($key_check == NULL) {
$mph_error = 'Error: Invalid MiningPoolHub API KEY';
} else{
if ($auth_user->update_mph_api($userRow['user_id'].$mph_key)) {
$mph_success = 'Success: MiningPoolHub API KEY updated.';
}
}
}
}
}
if(isset($mph_error))
{
?>
<div class="alert alert-danger alert-dismissible">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true" style="color: white;">×</button>
<h4><i class="icon fa fa-ban"></i> Alert!</h4>
<?php echo $mph_error; ?>
</div>
<?php
}
if(isset($ncheck_error))
{
?>
<div class="alert alert-danger alert-dismissible">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true" style="color: white;">×</button>
<h4><i class="icon fa fa-ban"></i> Alert!</h4>
<?php echo $ncheck_error; ?>
</div>
<?php
}
if(isset($error))
{
?>
<div class="alert alert-danger alert-dismissible">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true" style="color: white;">×</button>
<h4><i class="icon fa fa-ban"></i> Alert!</h4>
<?php echo $error; ?>
</div>
<?php
}
if (isset($success) || isset($file_get_contents)) { ?>
<div style="display: inline-block; width: 50%; float: right;">
<div class="alert alert-danger alert-dismissible" >
<button type="button" style="color: white;" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<h4><i class="icon fa fa-ban"></i> Oops!</h4>
<?php echo $file_get_error; ?>
</div>
</div>
<div style="display: inline-block; width: 50%;">
<div class="alert alert-success alert-dismissible" >
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<h4><i class="icon fa fa-check"></i> Success!</h4>
<?php echo $success; ?>
</div>
</div>
<?php } elseif (isset($success))
{
?>
<div class="alert alert-success alert-dismissible">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<h4><i class="icon fa fa-check"></i> Success!</h4>
<?php echo $success; ?>
</div>
<?php
} ?>
我认为我对错误有点无意义,在表单开始工作后会解决这个问题。
发布在同一页面上的任何线索?
感谢您的帮助:)
答案 0 :(得分:1)
试试这个:
<?php
if (isset($_REQUEST['form1'])) {
//your code
}
if (isset($_REQUEST['form2'])) {
//your code
}
if (isset($_REQUEST['form3'])) {
//your code
}
?>
<form action="">
<form action="">
<input type="submit" name="form3">
</form>
<input type="submit" name="form1">
</form>
<form action="">
<input type="submit" name="form2">
</form>