我正在为一个班级的项目工作,我有一个登录页面(带有用户名和密码),可以打开另一个页面。有没有办法可以自定义该页面上的标题来说" Hello 用户名"?
<center> <h2>Hello <script> name = document.getElementById('email').value; document.write(name); </script> ! </h2></center>
我确定必须有一个真正简单的方法来做这样的事情?我一直在寻找,但没有运气,谢谢。
答案 0 :(得分:0)
- One way of doing is store the username in the cookie on the login page
$cookie_username = "username";
$cookie_value = "xyz";
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/");
- read the cookie on the second page
if(isset($_COOKIE[$cookie_username])) {
hello $_COOKIE[$cookie_username] ;
}
答案 1 :(得分:0)
<script>
function personalizeHeader(){
name = document.getElementById('email2').value;
document.getElementById("header").innerHTML = "Hello " + name + "!";
}
</script>
<div id="Login" style="display:show">
<div class="row">
<div class="col">
username
</div>
<div class="col">
<input type="Text" placeholder="email" name="email2" id="email2"></br>
</div>
</div>
<div class="row">
<div class="col">
Password
</div>
<div class="col">
<input type="Text" name="password" id="password"></br>
</div>
</div>
<div class="row">
<button onclick="showForm();">Login </button>
</div>
</div>
<center> <h2 id="header"> </h2></center>