-1

在我下面的 php 中,我有一个忘记密码的东西,它会根据某些条件回显一个表单,我将如何用我的 css 设置它的样式?因为我不希望表格在没有任何样式的情况下显示

我已经尝试并试图弄清楚该怎么做,但什么都没有。我什至试着想把它写成几页,但感到困惑和迷失

    <?php

require("core/dbc.php");

if(isset($_GET['code']))
{
    $get_username = $_GET['username'];
    $get_code = $_GET['code'];

    $query = mysql_query("SELECT * FROM users WHERE username='$get_username'");

    while($row = mysql_fetch_assoc($query))
    {
        $db_code = $row['passreset'];
        $db_username = $row['username'];    
    }
    if($get_username == $db_username && $get_code == $db_code)
    {
    echo "

    <form action='pass_reset_complete.php?code=$get_code' method='POST'>
            Enter A New Password<br><input type='password' name='newpass'><br>
            Re-Enter Your New Password<br><input type='password' name='newpass1'><p>
            <input type='hidden' name='username' value='$db_username'>
            <input type='submit' value='Update Password'>
        </form>
        ";
    }
}
if(!isset($_GET['code']))
{


    echo "

<form action='forgot_pass.php' method='POST'>
    Enter Your Username<br><input type='text' name='username'><p>
    Enter your email<br><input type='text' name='email'><p>
    <input type='submit' value='Submit' name='submit'>
</form>
";

if(isset($_POST['submit']))
{
    $username = $_POST['username'];
    $email = $_POST['email'];   

    $query = mysql_query("SELECT * FROM users WHERE username='$username'");
    $numrow = mysql_num_rows($query);
    if($numrow!=0)

    {
        while($row = mysql_fetch_assoc($query))
        {
            $db_email = $row['email'];
        }
        if($email == $db_email)
        {
            $code = rand(10000,1000000);

            $to = $db_email;
            $subject = "Password Reset";
            $body = "

            This is a automated email. PLEASE DO NOT REPLY TO THIS MESSAGE

            Click the link below or paste it into your browser
            http://localhost:8080/signup-project/signup-project/registration%20and%20login/forgot_pass.php?code=$code&username=$username


            ";

            mysql_query("UPDATE users SET passreset='$code' WHERE username='$username'");

            mail($to,$subject,$body);

            echo "Check Your Email For Your New Password";
        }
        else
        {
            echo "the email is incorrect";
        }
    }
    else
    {
        echo "that username does not exist";
    }
}
}
?>

好的,我很困惑,因为很多人都在说不同的方式,所以让我试试这个,我将放置我的 css 文件代码,然后我将粘贴我的登录表单代码(我有这个 css 工作的地方'

这是我的 .css 文件中的代码

    body {
    line-height: 1.4;
    background-color: #666;
    font-family: Arial, Helvetica, sans-serif;
}

h1 {
    font-family: 'Roboto', sans-serif;
}

.hidden {
    display: none;
}

a, 
a:active,
a:focus
a:visited {
    color: #1B9BE0 ;
    text-decoration: none;
}

a:hover {
    text-decoration: underline
}

/* Structure */


#wrap {
    width: 960px;
    margin: 0 auto;
    padding: 20px;
    background-color: #fff;
    -webkit-box-shadow: 1px 1px 5px rgba(50, 50, 50, 0.75);
    -moz-box-shadow: 1px 1px 5px rgba(50, 50, 50, 0.75);
    box-shadow: 1px 1px 5px rgba(50, 50, 50, 0.75);

}

#head {
    text-align: center;
}

.form-wrap {
    width: 600px;
    margin: 0 auto;

}

.content {
    overflow: hidden;
}

.user-controls {
    float: right;

}

.logged-in-user{
    float: right;
    margin-left: 140px;
}

.logged-in-user p {
    margin: 0;
}

/* Form Elements */

fieldset {
    border: 0;
    padding: 0;
}

.form-el {
    margin: 10px 0;
}

.btn {
    display: inline-block;
    padding: 4px 12px;
    margin-bottom: 0;
    font-size: 14px;
    line-height: 20px;
    color: #333333;
    text-align: center;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
    vertical-align: middle;
    cursor: pointer;
    background-color: #f5f5f5;
    background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6);
    background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6));
    background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6);
    background-image: -o-linear-gradient(top, #ffffff, #e6e6e6);
    background-image: linear-gradient(to bottom, #ffffff, #e6e6e6);
    background-repeat: repeat-x;
    border: 1px solid #cccccc;
    border-color: #e6e6e6 #e6e6e6 #bfbfbf;
    border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
    border-bottom-color: #b3b3b3;
    -webkit-border-radius: 4px;
    -moz-border-radius: 4px;
    border-radius: 4px;
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe6e6e6', GradientType=0);
    filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
    -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
    -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
}

input[type="text"],
input[type="number"],
input[type="password"],
textarea {
    background-color: #fff;
    border: 1px solid #ccc;
    -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
    -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
    -webkit-transition: border linear .2s,box-shadow linear .2s;
    -moz-transition: border linear .2s,box-shadow linear .2s;
    -o-transition: border linear .2s,box-shadow linear .2s;
    transition: border linear .2s,box-shadow linear .2s;
    padding: 8px 4px;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
    width: 270px;
    font-size: 18px;
}

input[type="text"]:hover,
input[type="number"] :hover,
input[type="password"]:hover {
    border-color: rgba(82, 168, 236, 0.8);
    outline: 0;
    outline: thin dotted 9;
    -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
    -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
}

input[type="submit"] {
    color: #ffffff;
    text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
    background-color: #006dcc;
    background-image: -moz-linear-gradient(top, #0088cc, #0044cc);
    background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc));
    background-image: -webkit-linear-gradient(top, #0088cc, #0044cc);
    background-image: -o-linear-gradient(top, #0088cc, #0044cc);
    background-image: linear-gradient(to bottom, #0088cc, #0044cc);
    background-repeat: repeat-x;
    border-color: #0044cc #0044cc #002a80;
    border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
}

现在这是我的登录表单,上面有 css

<html>
<head>
<meta charset="utf-8">
<title>Log-In</title>
<link href='http://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'/>
<link href="../css/core.css" rel="stylesheet" />
</head>

<body>


<div id="wrap">
    <div id="head">
        <h1>Login to the Assignment Upload System</h1>
    </div>

    <div class="content">


        <form action="core/authenticate.php" method="POST">
            <div class="form-wrap">
                <fieldset>
                    <legend class="hidden">Login</legend>
                    <div class="form-el">
                        <label class="hidden" for="username">User name</label>
                        <input id="username" type="text" name="username" placeholder="Enter Your Username..."><br />
                    </div>
                    <div class="form-el">
                        <label class="hidden" for="password">Password</label>
                        <input id="password" type="password" name="password" placeholder="Enter Your Password..."><br />
    <a href="forgot_pass.php">Forgot Password?</a>                        
                    </div>
                    <input class="btn" type="submit" value="Login">
                </fieldset>
            </div>

        </form>
    </div>
    <?php if(isset($_GET["feedback"])){echo $_GET["feedback"];} ?>


</div>


</body>
</html>

现在我希望我的 php 中的 echo 表单看起来与这个页面完全一样,那么我该怎么做呢?因为我对人们在说什么感到非常困惑

4

3 回答 3

0

一个简单的方法是包含引导程序:

将其包含在<head>

<link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" media="screen" />

然后在所有输入中添加class="form-control"

例如:

<input type="text" class="form-control" />
于 2013-09-22T05:33:13.917 回答
-1

只需确保将 CSS 文件包含在使用 PHP 代码生成的 HTML 文件中即可。

<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
于 2013-09-22T05:30:07.043 回答
-1

给表单一个这样的类名:

回声“

<form action='pass_reset_complete.php?code=$get_code' method='POST' class='first_form'>
        Enter A New Password...etc

然后在 PHP 代码中添加样式标签:

<style>
.first_form{
    background:#ccc;
    width:300px;
    border:solid #000 1px;
}
</style>

并且您可以像这样设置输入标签的样式:

<style>
.first_form{
    background:#ccc;
    width:300px;
    border:solid #000 1px;
}
.first_form > input[type=password]{
     width:250px;
     color:#fff;
     background:#333;
 }
 .first_form > input[type=submit]{
     width:70px;
     border:none;
 }
</style>
于 2013-09-22T05:45:16.790 回答