我有註冊表單,我需要隱藏提交按鈕。這個按鈕在PHP中執行後會顯示出來。如何通過PHP在HTML按鈕上添加CSS類
我試圖使用CSS類,它的工作原理,但我不知道如何添加一個類與PHP。
這裏是一流的按鈕,我想改變:
<form method="post" action="register.php" name="registerform">
<input type="submit" name="register" value="registrovat" id="button8" class=I don't know what /><br><br>
</form>
我的CSS:
#button8{
visibility: hidden;
font-family: century gothic;
color: #0099FF;
border: 2px solid #0099FF;
background: transparent;
}
#button8.visible{
visibility: visible;}
我需要改變,以button8.visible但在PHP(我的條件取決於MySQL數據)。
編輯:
我需要它,因爲,基於代碼的按鈕將是可見的。用戶輸入代碼後,按下一個按鈕。此操作將運行PHP:連接到mySQL查找此代碼是否在數據庫中。如果是,我需要我的按鈕可見。由於我的知識水平低,我希望在同樣的PHP會話中使用if語句,其中mySQL。這裏是整個代碼:
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<title>Panákovač 4.0</title>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
</head>
<body>
</body>
</html>
<?php
// show potential errors/feedback (from registration object)
if (isset($registration)) {
if ($registration->errors) {
foreach ($registration->errors as $error) {
echo $error;
}
}
if ($registration->messages) {
foreach ($registration->messages as $message) {
echo $message;
}
}
}
?>
<!-- register form -->
<form method="post" action="register.php" name="registerform">
<input id="login_input_username" class="login_input" type="text" pattern="[a-zA-Z0-9]{2,64}" name="user_name" placeholder="uživatelské jméno" required /><br>
<input id="login_input_password_new" class="login_input" type="password" name="user_password_new" pattern=".{6,}" placeholder="heslo (min. 6 znaků)" required autocomplete="off" /><br>
<input id="login_input_password_repeat" class="login_input" type="password" name="user_password_repeat" pattern=".{6,}" placeholder="zopakujte heslo" required autocomplete="off" /><br>
<input id="login_input_firstname" class="login_input" type="text" name="user_firstname" placeholder="jméno" required /><br>
<input id="login_input_lastname" class="login_input" type="text" name="user_lastname" placeholder="příjmení" required /><br>
<input id="login_input_email" class="login_input" type="email" name="user_email" placeholder="e-mail" required /><br>
<input id="login_input_company" class="login_input" type="text" name="user_company" placeholder="firma" required /><br>
<input type="submit" name="register" value="registrovat" id="button8" class= /><br><br>
</form>
<form method="post" action="register.php" name="registerform">
<input id="login_input_code" class="login_input" type="text" name="user_code" placeholder="ověřovací kód" required /><br>
<input type="submit" name="kod" value="ověřit kód"/><br>
</form>
<?php
if(isset($_POST['kod'])){
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "login";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$user_code = $_POST['user_code'];
$sql = "SELECT `used`,`code` FROM `regcode` WHERE `code` LIKE '$user_code' ";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "kód: " . $row["code"]. " - použito: " . $row["used"]. $zob . "<br>";
$pouzito = $row["used"];
MY CONDION FOR CLASSES
}
} else {
echo "chybný kód" . $user_code;
}
$conn->close();
}
?>
你爲什麼不使用JavaScript?你試圖做的事情並不完全有意義 – clearshot66
在php中使用條件。類似於?>' –
它確實有意義,但是讓整個按鈕以MySQL結果爲條件會更簡單結果。如果您需要更多幫助,我們需要查看您的PHP來檢索此結果。 –