在PHP中使用GET时,CSS样式不起作用

时间:2018-02-18 11:52:44

标签: php css database

我一直在为我正在处理的网站编写一个php脚本,并注意到所有外部样式在所有文件中都正常工作,除了唯一一个从表单中获取带有GET关键字的值的文件。这是代码

<?php
session_start();

    //previous elements
    $del_id = $_GET["id"];
    $del_name = $_GET["name"];
    $del_phone = $_GET["phone"];
    $del_address = $_GET["address"];
    $del_email = $_GET["email"];
/*    
    echo $del_id.'<br>';
    echo $del_name.'<br>';
    echo $del_phone.'<br>';
    echo $del_address.'<br>';
    echo $del_email.'<br>';   
    */
    if(isset($_POST["name"]) || isset($_POST["address"]) || isset($_POST["number"]) || isset($_POST["email"])){
        echo "NEW";
        //new elements
        $name2 = $_POST["name"];
        $address2 = $_POST["address"];
        $number2 = $_POST["number"];
        $email2 = $_POST["email"];
        $id2 = $_POST["id"];
        /*echo $name2;
        echo "<br>";
        echo $address2;
        echo "<br>";
        echo $number2;
        echo "<br>";
        echo $email2;
        echo "<br>";
        echo $id2; 
        echo "<br>";
        */

        $query = "UPDATE `contacts` SET email = '$email2', phone = '$number2', address = '$address2', name = '$name2' WHERE id = '$id2'";        
        //DB CONNECTION STUFF
        $servername = "localhost";
        $username = "57385";
        $password = "AM57385";
        $dbname = "db_57385";
        $conn  = mysqli_connect($servername,$username,$password,$dbname);    
        //Check connection
        if(!$conn){
            die("Connection failed: ".mysqli_connect_error());
        }else{
            //echo "Connected successfully";
        }   

        if(mysqli_query($conn,$query)){
            //echo "<br> Contact edited";
        }    

    }

?>


<html>
    <head>
        <title> </title>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <meta name="description" content="" />
        <meta name="keywords" content="" />
        <!--[if lte IE 8]><script src="css/ie/html5shiv.js"></script><![endif]-->
        <script src="js/jquery.min.js"></script>
        <script src="js/jquery.dropotron.min.js"></script>
        <script src="js/jquery.scrollgress.min.js"></script>
        <script src="js/jquery.scrolly.min.js"></script>
        <script src="js/jquery.slidertron.min.js"></script>
        <script src="js/skel.min.js"></script>
        <script src="js/skel-layers.min.js"></script>
        <script src="js/init.js"></script>
        <noscript>
            <link rel="stylesheet" href="css/skel.css" />
            <link rel="stylesheet" href="css/style.css" />
            <link rel="stylesheet" href="css/style-xlarge.css" />
        </noscript>
        <!--[if lte IE 9]><link rel="stylesheet" href="css/ie/v9.css" /><![endif]-->
        <!--[if lte IE 8]><link rel="stylesheet" href="css/ie/v8.css" /><![endif]-->
    </head>
    <body class="landing">

        <!-- Header -->
            <header id="header" class="alt skel-layers-fixed">
                <nav id="nav">
                    <ul>
                        <li><a href="index.html">Home</a></li>
                        <li>
                            <a href="" class="icon fa-angle-down">Περιήγηση</a>
                            <ul>
                                <li><a href="http://dalab.ee.duth.gr/~57385/files/login.php?">Συνδεθείτε</a></li>
                                <li><a href="http://dalab.ee.duth.gr/~57385/files/sign_up.php?">Κάνετε εγγραφή</a></li>
                                <li><a href="http://dalab.ee.duth.gr/~57385/files/main.php?">Σελίδα καταλόγου</a></li>

                            </ul>
                        </li>
                    </ul>
                </nav>
            </header>

        <!-- Banner -->
            <section id="banner">
                <div class="inner">
                    <form action="edit.php" method = "POST">
                      EDIT CONTACT<br><br>
                        NAME<input type="text" value="<?php echo $del_name?>" name="name"><br>        
                        ADDRESS<input type="text" value="<?php echo $del_address?>" name="address"><br>  
                        PHONE NUMBER <input type="text" value="<?php echo $del_phone ?>" name="number"><br>  
                        EMAIL <input type="text" value="<?php echo $del_email ?>" name="email"><br>
                        id  <input type="text" value="<?php echo $del_id ?>" name="id" readonly><br>

                      <input type="submit" value="Submit">
                    </form>
                </div>
            </section>

        <!-- Footer -->
            <footer id="footer">

                <ul class="menu">
                    <li><a href="#">Name</a></li>

                </ul>
                <span class="copyright">
                    &copy; Copyright. All rights reserved
                </span>
            </footer>

    </body>
</html>

通过POST获取其值的所有其他脚本或其URL中没有任何其他脚本按预期显示。即使是这个,当我从值清除URL并只键入link / filename.php时,它会正常显示。虽然因为我需要它们,但是不可能以POST方式执行它

1 个答案:

答案 0 :(得分:0)

<style>
p.fm {
    color: #b92160;
}

input[type="text"] {
    background: bisque;
}
</style>

       <form action="edit.php" method = "POST">
                      <h3>EDIT CONTACT</h3>
                      <p class="fm">
                      <label for="name">Name:</label><br />
                        <input type="text" value="<?php echo $del_name;?>" name="name"><br>
                         </p>

                        <p class="fm">
                        <label for="name">ADDRESS:</label><br />       
                        <input type="text" value="<?php echo $del_address;?>" name="address"><br>
                        </p>

                        <p class="fm">
                         <label for="name">PHONE NUMBER:</label><br />
                          <input type="text" value="<?php echo $del_phone; ?>" name="number"><br>
                         </p>

                        <p class="fm">
                        <label for="name">EMAIL:</label><br />  
                         <input type="text" value="<?php echo $del_email; ?>" name="email"><br>
                        </p>

                        <p class="fm">
                        <label for="name">ID:</label><br />
                          <input type="text"  value="<?php echo $del_id; ?>" name="id" readonly><br>
                        </p>

                      <p>
                      <input type="submit"  id="submit" value="Submit">
                      </p>
                    </form>

试试这个