Это PHP-код для флажков:Как отобразить ввод пользователя в флажках?
<b>Interests:</b> <input type="checkbox" name="interests" value="interests">Nature/Wildlife
<input type="checkbox" name="interests" value="interests">Arts/Museum
<input type="checkbox" name="interests" value="interests">Neighbourhoods
Как отобразить пользовательский ввод в следующей странице? Показывать только те, которые пользователь отметил.
делает его выглядеть как
Интересы:
Nature/Wildlife
Arts/Museum
Использование $ _POST метод
Показаны полный код:
<head>
<link rel="stylesheet" href="styles.css">
<style>
#nav {
text-align:left;
}
</style>
</head>
<body>
<div id="header">
<h1> <img src="images/footprints.jpg"> Singapore Footprints</h1>
</div>
<div id="nav">
<form action="visitorProfile.php" method="post">
<p>
<!-- Write codes to add a textbox for name -->
<b>Name:</b> <input type="text" name="name" size="20" maxlength="40"value=""/>
</p>
<p>
<!-- Write codes to add a textbox for userid -->
<b>Userid:</b> <input type="text" name="Userid" size="20"/>
</p>
<p>
<!-- Write codes to add a textbox for password -->
<b>Password:</b> <input type="password" name="pwd" size="20"/>
</p>
<p>
<!-- Write codes to add a textbox for contact number -->
<b>Contact Number:</b> <input type="text" name="contactno" size="20"/>
</p>
<p>
<!-- Write codes to add radio buttons for status, either local or tourist -->
<b>Status:</b> <input type="radio" name="Status" value="local">Local
<input type="radio" name="Status" value="tourist">Tourist</br>
</p>
<p>
<!-- Write codes to add checkboxes for interests -->
<b>Interests:</b> <input type="checkbox" name="interests[]" value="Nature/Wildlife">Nature/Wildlife
<input type="checkbox" name="interests[]" value="Arts/Museum">Arts/Museum
<input type="checkbox" name="interests[]" value="Neighbourhoods">Neighbourhoods
</p>
<input type="submit" name="submit" value="Register me!" />
<input type="reset" value="Reset" />
</form>
</div>
<div id="footer">
Copyright © School of IIT
</div>
</body>
</html>
Какие ссылки на это:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="styles.css">
<style>
#nav {
text-align:centre;
}
</style>
</head>
<body>
<?php
$name=$_POST['name'];
$userid=$_POST['Userid'];
[email protected]$_POST['contactno'];
$status=$_POST['Status'];
?>
<div id="header">
<h1> <img src="images/footprints.jpg"> Singapore Footprints</h1>
</div>
<div id="nav">
Thank you for registering with us.
<?php
echo "Thank you, <b>$name</b>.<br/>";
echo '</p>';
echo "<b>You have entered the following details:</b><br/>";
echo "<b>Userid:</b> $userid <br/>";
echo "<b>Contact Number:</b> $contactno <br/>";
echo "<b>Status:</b> $status <br/>";
$topics = $_POST['interests'];
if(empty($topics))
{
echo("You didn't select anything");
}
else
{
$N = count($topics);
echo("You selected $N topic(s): ");
for($i=0; $i < $N; $i++)
{
echo($topics[$i] . " ");
}
}
?>
<br> <br>
Please <a href="comments.html">Click Here</a> to continue.
</div>
<div id="footer">
Copyright © School of IIT
</div>
</body>
</html>
'значение = "Природа/Дикая природа"'? Зачем вам устанавливать значение ** SAME ** для трех разных флажков? –
Для этого нужен бэкэнд-язык, такой как PHP, ASP.NET, JAVA и т. Д. Также вам нужно настроить сервер даже локально или удаленно. В основном вы пропустите базовые знания того, что делает HTML, и что делает серверный сервер на сервере. –