gpt4 book ai didi

php - 链接在 PHP 中不起作用或无法正确显示

转载 作者:太空宇宙 更新时间:2023-11-04 06:29:03 24 4
gpt4 key购买 nike

我在 html 文件中设计了一个页眉,一切正常,但是当我将它放入 .php 文件中时,它们变得空闲,所以我无法单击或悬停它们。 PHP代码:

<?php
session_start();
require_once "stuff.php";
if (isset($_SESSION['encnick'])){
header("Location: my.php");
return;
}
//On form submit
if (isset($_POST['register'])){
if (!isset($_POST['nick'])){
$_SESSION['error'] = "Nickname is required";
header("Location: register.php");
return;
}
if (!isset($_POST['password'])){
$_SESSION['error'] = "Password is required";
header("Location: register.php");
return;
}
if (!isset($_POST['cpassword'])){
$_SESSION['error'] = "Password is required";
header("Location: register.php");
return;
}
if ($_POST['password'] !== $_POST['cpassword']){
$_SESSION['error'] = "Passwords don't match";
header("Location: register.php");
return;
}
else{
$statement = $pdo->prepare("SELECT * FROM users WHERE nick = :nick");
$statement->execute(array(':nick' => $_POST['nick']));
$row = $statement->fetch(PDO::FETCH_ASSOC);
if ($row['nick'] === $_POST['nick']){
$_SESSION['error'] = "This nickname is already taken";
header("Location: register.php");
return;
}
$statement = $pdo->prepare("INSERT INTO users (nick, password, company, encodednick, user_group) VALUES (:nick, :password, :company, :encodednick, :user_group)");
$statement->execute(array(
':nick' => htmlentities($_POST['nick']),
':password' => password_hash($_POST['password'], PASSWORD_BCRYPT),
':company' => htmlentities($_POST['company']),
':encodednick' => md5($_POST['nick']),
':user_group' => "user"
));
$_SESSION['encnick'] = md5($_POST['nick']);
$encnick = $_SESSION['encnick'];
header("Location: my.php?id=$encnick");
return;
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>ReactSynchro</title>
<link rel="stylesheet" href="css/register.css">
<link rel="stylesheet" href="css/fonts.css">
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<?php printheader() ?>
<div id="formdiv">
<form method="post">
<label for="nick">Nickname</label>
<input type="text" name="nick" id="nick" placeholder="Enter unique nickname" minlength="6" maxlength="30" required>
<label for="password">Password</label>
<input type="password" name="password" id="password" placeholder="Enter password" minlength="8" maxlength="60" required>
<label for="cpassword">Confirm Password</label>
<input type="password" name="cpassword" id="cpassword" placeholder="Confirm password" minlength="8" maxlength="50" required>
<label for="company">Company</label>
<input type="text" name="company" id="company" placeholder="Enter your company" minlength="3" maxlength="50">
<input type="submit" value="Register" name="register" id="regbtn">
</form>
</div>
<?php
if (isset($_SESSION['error'])){
echo "<h2 id='errormessage'>".$_SESSION['error']."</h2>";
unset($_SESSION['error']);
}
?>
</body>
</html>

main.css代码:

body{
background-color: #333;
margin: 0;
}
#header{
width: 100%;
position: fixed;
top: 0;
left: 0;
right: 0;
background-color: #444;
height: 110px;
}
#header img{
height: 100px;
position: relative;
left: 5px;
top: 5px;
bottom: 5px;
}
#header a{
color: white;
text-decoration: none;
display: block;
position: relative;
float: left;
text-align: center;
margin: 5px;
padding: 5px;
border: 0.5px solid white;
font-family: 'Ubuntu';
font-size: 20px;
-webkit-transition: background-color 200ms linear;
-ms-transition: background-color 200ms linear;
transition: background-color 200ms linear;
-moz-transition: background-color 200ms linear;
-o-transition: background-color 200ms linear;
}
#hlinks1{
position: relative;
left: 120px;
top: -71px;
}
#hlinks2{
position: absolute;
right: 5px;
top: 50%;
transform: translateY(-50%);
}
#hlinks2 a{
background-color: rgba(255, 140, 0, 0.9);
}
#hlinks1 a:hover{
background-color: rgba(255, 255, 255, 0.1);
}
#hlinks2 a:hover{
background-color: rgba(255, 140, 0, 1);
}
#errormessage{
color: red;
text-align: center;
font-family: 'Ubuntu';
}
@media all and (max-width: 537px){
#hsupbtn{
visibility: hidden;
}
}
@media all and (max-width: 440px){
#hregbtn{
visibility: hidden;
}
}

register.css代码:

#formdiv{
width: 50%;
height: 350px;
position: absolute;
left: 0;
right: 0;
margin: auto;
top: 50%;
transform: translateY(-50%);
border: 0.5px solid white;
max-width: 500px;
min-width: 250px;
}
#formdiv label{
text-align: center;
font-family: 'Ubuntu';
color: white;
width: 100%;
display: block;
font-size: 24px;
line-height: 50px;
}
#formdiv input{
width: 90%;
position: relative;
margin: auto;
display: block;
font-family: 'Ubuntu';
line-height: 20px;
}
#regbtn{
width: 50% !important;
top: 20px;
background-color: rgba(255, 140, 0, 0.9);
color: white;
-webkit-transition: background-color 200ms linear;
-ms-transition: background-color 200ms linear;
transition: background-color 200ms linear;
-moz-transition: background-color 200ms linear;
-o-transition: background-color 200ms linear;
}
#regbtn:hover{
background-color: rgba(255, 140, 0, 1);
}
#formdiv input:empty{
border: 0.5px solid white;
}
#formdiv input:valid{
border: 0.5px solid green;
}

stuff.php文件中的菜单打印函数:

function printheader(){
echo "<div id='header'>
<img src='images/logo.png'>
<div id='hlinks1'>
<a href='../index.php'>Home</a>
<a href='../about.html'>About</a>
<a href='../support.php' id='hsupbtn'>Support</a>
</div>
<div id='hlinks2'>
<a href='../register.php' id='hregbtn'>Register</a>
<a href='../login.php'>Login</a>
</div>
</div>
<div style='height: 110px; position: relative;'></div>";
}

所以我的意思是,当我悬停或单击链接时,什么也没有发生,它们像图片一样空闲,但如果我断开 main.css 文件,它们就会开始正常工作。

最佳答案

您的打印头功能

<div style='height: 110px; position: relative;'></div>

删除以下内容:-

position: relative

关于php - 链接在 PHP 中不起作用或无法正确显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54842003/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com