Home > Backend Development > PHP Tutorial > 用PHP在主页MAIN.PHP中让用户自定义添加内容,有码求帮助

用PHP在主页MAIN.PHP中让用户自定义添加内容,有码求帮助

WBOY
Release: 2016-06-13 13:12:56
Original
1082 people have browsed it

用PHP在首页MAIN.PHP中让用户自定义添加内容,有码求帮助
以下代码肯定有问题,试过了,我刚入门,求各位帮助!


我的思路是这样的:
先在MAIN.PHP中输入所有自定义内容的HTML代码,譬如用户可以自定添加至多2个内容快,A和B,我先在主页中写:

HTML code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
<div id="<?php echo $widgets1 ?>">
A
</div>

<div id="<?php echo $widgets2 ?>">
B
</div>

然后在CSS中设置:

[code=CSS]
#a {
display:none;
}

#b {
display:none;
}

#a1 {
}

#b1 {
}

Copy after login

[/code]
也就是说通过在自定义.PHP页面中的checkbox勾选所需的内容块然后。。

  setcookie("events", $_POST['events'], $now + (60));
 setcookie("friends", $_POST['friends'], $now + (60));
PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->   if(isset($_COOKIE['events'])) {
      $widgets1 = $_COOKIE['events'];
   } else {
      $widgets1 = "eventsshow";
      
   }
   
   if(isset($_COOKIE['friends'])) {
      $widgets2 = $_COOKIE['friends'];
   } else {
      $widgets2 = "friendsshow";
      
   }

   
Copy after login
Widgets >
>
?>




------解决方案--------------------
既然是为了控制快的显示与否
那么就应该动态设置块的id,值总是 a、b、a1、b1 之一
实在不知道你在哪里做了此类操作
------解决方案--------------------
radio是一组用同一个name,checkbox是每个用单独的name
为何没见到你用name?
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template