Итак, я застрял с этим около дня, подумал, может быть, stackoverflow сможет помочь.
У меня есть форма в этой форме, есть таблица, и в этой таблице каждая строка (1-2) имеет формы, которые необходимо разместить на той же странице. Пока у меня работает форма NiceHash, хотя сообщение для MPH, похоже, не работает, независимо от того, какую работу я пытаюсь решить. что я пытался сделать до сих пор Как разместить две формы на одной странице? & 2 формы на одной странице 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
} ?>
Я думаю, что уловил немного бессмыслицы с ошибками, собирался исправить это после того, как формы начали работать.
Есть какие-нибудь подсказки для публикации на той же странице?
Спасибо за вашу помощь :)






Попробуй это:
<?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>