<!doctype html>
<html>
<head>
<meta charset="utf-8">
<!-- TemplateBeginEditable name="doctitle" -->
<title>REGISTRATION</title>
<!-- TemplateEndEditable -->
<!-- TemplateBeginEditable name="head" -->
<!-- TemplateEndEditable -->
</head>
<body>
<?php
session_start();
$_SESSION["message"] = "";
$mysqli = new MySQLi("localhost","root","","accounts");
if ($_SERVER['REQUEST_METHOD'] == "POST"){
$username = $mysqli->real_escape_string($_POST["username"]);
$email = $mysqli->real_escape_string($_POST["email"]);
$dday = ($_POST["day"]);
$indexno = ($_POST["indexno"]);
$_SESSION["username"] = $username;
$_SESSION["email"] = $email;
$sql = "INSERT INTO users (`indexno`, email, name, day) "."VALUES ('$indexno', '$email', '$username', '$dday');";
//check if mysql query is successful
if ($mysqli->query($sql) === true)
{
$_SESSION[ 'message' ] = "Registration succesful! Added $username to the database!";
//redirect the user to welcome.php
header( "location: welcome.php" );
}
else{
$_SESSION["message"] = "user could not be added to the database";
}
}
else{
$_SESSION["message"] = "could not initate seesion";
}
?>
<link href="//db.onlinewebfonts.com/c/a4e256ed67403c6ad5d43937ed48a77b?family=Core+Sans+N+W01+35+Light" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" href="form.css" type="text/css">
<div class="body-content">
<div class="module">
<h1>Create an account</h1>
<form class="form" action="form.php" method="post" enctype="multipart/form-data" autocomplete="off">
<div class="alert alert-error"></div>
<input type="text" placeholder="User Name" name="username" required />
<input type="email" placeholder="Email" name="email" required />
<br>
<input type="text" placeholder="index Number" name="indexno" required /><br>
<input type="submit" value="Register" name="register" class="btn btn-block btn-primary" />
<input type="radio" name="day" id="mond"
<?php
$result=mysqli_query("SELECT day=('monday'), COUNT(*) FROM users GROUP BY day");
$data=mysqli_fetch_assoc($result);
if(isset($dday) && $dday=='monday') echo 'checked';
if($data>=8) echo 'disabled';
?>
value="monday" required>Monday 08:30 AM - 10:30 AM <br>
<input type="radio" name="day" id="frid"
<?php if (isset($dday) && $dday=="friday") echo "checked";
?>
value="friday" required>Friday 02:00 PM - 04:30 PM <br>
<input type="radio" name="day"
<?php if (isset($dday) && $dday=="saturday") echo "checked";?>
value="saturday" required>Saturday 02:00 PM - 04:30 PM <br>
<input type="radio" name="day"
<?php if (isset($dday) && $dday=="sunday") echo "checked";?>
value="sunday" required>Sunday 08:30 AM - 10:30 AM <br>
</form>
</div>
</div>
</body>
</html>
->
<input type="radio" name="day" id="mond"
<?php if (isset($dday) && $dday=="monday") echo "checked";
if($data>=8) echo("function disable() {
doccument.getElementById("mond").disabled = true;
}") ?>
value="monday" required>Monday 08:30 AM - 10:30 AM <br>
如果数据变量达到8,我希望禁用此单选按钮。它在doccument.get .....行中显示意外的变量错误,请帮忙 ->更新 我添加了完整的cod eon顶部,因为用户询问了
我已经为此苦苦挣扎很长时间了。 该代码的目的是通过参考数据库中的数据来停止单选按钮被按下八次的操作。因此,我的想法是设置一个if条件以八次禁用单选按钮。
答案 0 :(得分:2)
您正在输入标签的中间输出javascrupt。
您只需要回显“已禁用”,就像这样:
setState(() {
double offset = 0.0; // offset to be set
if(_gridCount == 2) {
_gridCount = 1;
offset = offset1; // set offset1
} else {
_gridCount = 2;
offset = offset2; // set offset2
}
_scrollController.jumpTo(offset); // set proper offset
});
答案 1 :(得分:0)
以这种方式编码
在checked
之后添加空格,并为disabled
使用三进制
<?php
$dday="monday";
$data=9;
?>
<input type="radio" name="day" id="mond"
<?php if (isset($dday) && $dday=="monday") {echo "checked ";}
echo !empty($data)>=8?"disabled":''?> value="monday" required>Monday 08:30 AM - 10:30 AM <br>