这是我的一个小博客项目的管理页面,我从头开始学习PHP.这最初是来自phptoys的microNews.我做了很多改变,是的,代码可能更整洁. (我正在考虑制作一个“功能”页面,但这是为了以后)
<?php if (isset($_COOKIE['submitdate'])) { $submitDate=$_COOKIE['submitdate']; } else { $submitDate= date('Y-m-d'); } if (isset($_COOKIE['newstitle'])) { $newsTitle=$_COOKIE['newstitle']; } else { $newsTitle="News Title"; } //Set no caching header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); //create or edit file, protect this page from invalid users if (!isset($_POST['submit'])) { require_once('protector.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html> <head> //bootstrap stuff <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Basic Boring Blog</title> <link href="style/bootstrap.css" rel="stylesheet" type="text/css" /> <script language="javascript" type="text/javascript" src="js/tiny_mce.js"> </script> <script language="javascript" type="text/javascript"> tinyMCE.init({ mode : "textareas", theme : "advanced", theme_advanced_buttons3 : "", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", }); </script> <script language='javascript' type='text/javascript'> //delete that damn cookie function click_agree() { document.cookie = 'newstitle = $newsTitle ; expires = 2 Aug 1970 20:47:11 UTC; path=/'; document.cookie = 'submitdate = $submitDate ; expires = 2 Aug 1970 20:47:11 UTC; path=/'; } </script> <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!--[if lt IE 9]> <script src="http://img.558idc.com/uploadfile/allimg/210612/0924262Z8-1.jpg"> </script> <script src="http://img.558idc.com/uploadfile/allimg/210612/09242B0T-2.jpg"> </script> <![endif]--> </head> <body > //testing to see what the code knows //since bootstrap additions, this only outputs "News Title" <?php echo $newsTitle;?> </br> // this outputs nothing <?php echo $_COOKIE['newstitle'];?> <?php $filename = $submitDate.$newsTitle; ?> <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"> </script> <!-- Include all compiled plugins (below), or include individual files as needed --> <script src="js/bootstrap.min.js"></script> <div id="main2"> <?php include 'nav.php'; ?></div> <div id="main"> <?php //look into the specific file and see what the heck is there $newsData = file("news/news/".$filename.".txt"); $newsTitle = $newsData[0]; $submitDate = $newsData[1]; unset ($newsData['0']); unset ($newsData['1']); $newsContent = ""; foreach ($newsData as $value) { $newsContent .= $value; } ?> <div class="container-fluid"> <div class="well"> <div class="center-block"> <div class="form-group"> <form action='<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>' method='post' > <label>News Title</label> <br/> <input type='text' name='title' size='40' value="<?php echo $newsTitle;?>"/> <br/> <br/> <label>Write your thoughts here</label> <br/> <textarea name='newstext' rows='15' cols='67' /><?php echo $newsContent;?></textarea><br/> <div class="pull-right"><input type='submit' name='submit' value='Save' onClick='click_agree()' /></div> <br/> <br/> <br/> </form> </div></div> </div></div> </div></div> <?php include 'footer.php'; ?> </body> <?php } else { //make sure that variables are declared and then post this thing already $newsTitle = isset($_POST['title']) ? $_POST['title'] : 'Untitled'; if (isset($_COOKIE['submitdate'])) { $submitDate=$_COOKIE['submitdate']; } else { $submitDate= date('Y-m-d'); $newsContent = isset($_POST['newstext']) ? $_POST['newstext'] : 'No content'; $filename = $submitDate.$newsTitle; $f = fopen('news/news/'.$filename.".txt","w+"); //the page that will be made $written =" <html> <head> <meta charset='utf-8'> <meta http-equiv='X-UA-Compatible' content='IE=edge'> <meta name='viewport' content='width=device-width, initial-scale=1'> <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> <link href='style/bootstrap.css' rel='stylesheet' type='text/css' /> <meta name='viewport' content='width=device-width, initial-scale=1'> <title>Basic Boring Blog</title> <link href='http://pluckzilla.byethost32.com/microblog/microNews/style/bootstrap.css' rel='stylesheet' type='text/css' /> <script language='javascript' type='text/javascript'> function click_agree() { document.cookie = 'newstitle = $newsTitle; expires = 2 Aug 2017 20:47:11 UTC; path=/'; document.cookie = 'submitdate = $submitDate; expires = 2 Aug 2017 20:47:11 UTC; path=/'; window.location.href = 'http://www.pluckzilla.com/microblog/microNews/admin.php'; } </script> <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!--[if lt IE 9]> <script src='http://img.558idc.com/uploadfile/allimg/210612/0924262Z8-1.jpg'> </script> <script src='http://img.558idc.com/uploadfile/allimg/210612/09242B0T-2.jpg'></script> <![endif]--> </head> <body > <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js'> </script> <!-- Include all compiled plugins (below), or include individual files as needed --> <script src='js/bootstrap.min.js'></script> <div id=\"main2\"> <?php include 'nav.php'; ?> </div> <div> <div id='main' class='pull-right'> <span='title'><h1>$newsTitle</h1></span> <span='date'>$submitDate</span> <span><p>$newsContent</p></span> <button name='edit' onClick='click_agree()'><span class='glyphicon glyphicon-edit' aria-hidden='true'></span></button></div>
我有了新的页面,这个管理页面使用JavaScript()创建加载2个cookie,然后重定向回管理页面.然后,cookie将用于使用php调用上述创建的页面,并将其加载到表单上进行编辑.最后,表单按钮将删除cookie.
基本上,我启用了管理页面来编辑页面,而不仅仅是创建它们.
然后我添加了bootstrap,因为,它很棒.现在我的管理页面不起作用.
我不得不做错了什么,但我查看代码,除了引导位之外,一切看起来和以前一样.我删除了一些引导程序,主要来自表单,因为它是工作的关键,但它仍然不起作用.
…除此之外,我的“实时”服务器上的管理页面的代码在上面的表单上必须略有不同,而不是那个!作品!只是!精细!在我的localhost上.(基于Windows 7,wamp).我复制了WAS在服务器上工作的代码,并且在添加引导位时小心不要更改它.我无法在本地测试,唉,我没有成功.
简单的答案是No, CSS does not interfere with JavaScript.
从本质上讲,JavaScript能够改变页面中的内容,包括CSS,有时可能会使CSS看起来无法正常工作. (除非你有语法错误,CSS总是有效且非常可预测.如果它不适用于元素,则意味着它被另一个CSS规则或你不知道的内联样式覆盖).使用Bootstrap的CSS加载检查项目是否正常工作的一种非常简单的方法是在页面的head标签中添加此行(首先在本地计算机上尝试)并删除所有其他Bootstrap引用:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
但是,Bootstrap也附带了JavaScript.这可能会干扰页面中的其他JavaScript,但是,除非您在页面的不同插件/小部件中使用不同版本的Bootstrap,否则通常不会.从我在上面发布的代码中看到的,您正在使用Bootstrap中的CSS和Javascript.所以我想你的问题应该重新制定.
您能详细解释一下您的远程服务器上究竟有什么不可用,并且正在使用本地计算机吗?这可能与JavaScript无关.它可能与两台机器之间的Apache或php服务差异有关.