开源富HTML编辑器 [英] Open-source rich HTML editor

查看:139
本文介绍了开源富HTML编辑器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一名iPhone开发人员,他是网络开发的新手。我经验丰富的HTML和CSS,但我是新的PHP,并在我的Mac上安装MAMP。



我为一个需要基本CMS(我认为这是正确的术语!)。他们将需要编辑的基本信息,如主页文本,有关部分等。我设置为php包含在txt文件。像这样(在首页):

 <?php include'homeText.txt'?& 

我还设置了一个admin.php页面,管理员可以登录以编辑网站的内容。 (当我说登录时,我的意思是 if(username == x&&&&&&&&& $ b

在这个页面中,我想有一个下拉列表,允许用户选择一个文本文件打开,当他们选择一个文本文件时,它会在富文本编辑器中打开。 (任何格式化将是HTML,富文本编辑器将解析,以显示格式化的文本)。



有人知道一个合适的,开源的丰富的HTML编辑器,我可以轻松地嵌入到PHP页面,并将生成的HTML发送到PHP的帖子上

解决方案



/ div>

你做错了方式,我怀疑你可以开发应用程序这么快,因为你说你只是从昨天开始学习PHP,你的例子表明,你很低估了服务器的基础侧语言,你说你会检查登录与 if(username == x&&&< password == x)这是完全错误的做法,应该使用类似MySQL的数据库来存储和检查登录凭据,即通过$ _SESSION(会话变量),更准确地说,



考虑登录表单

 < form action =checkLogin.phpmethod =post> 
< input type =textname =username/>
< input type =passwordname =password/>
< input type =submitname =submitvalue =login/>
< / form>

拥有数据库总是更好,考虑以下数据库具有以下表和值。 p>

  CREATE TABLE`users'(
`id` int(11)NOT NULL AUTO_INCREMENT,
`name` varchar(50)NOT NULL,
`password` varchar(50)NOT NULL,
PRIMARY KEY(`id`),
);
INSERT INTO`users'VALUES('First User','6c049bc0f30da673d0a82c5bd1a13cde');
INSERT INTO`users'VALUES('Second User','6a6150f8eb2c263a31eb91487bebf1d6');
INSERT INTO`users'VALUES('Third User','2fd7e7348da8dd5f67103b15be525859');

第二个参数是密码的哈希值,我使用了 md5(),则可以使用 sha1()

现在要检查登录凭据,您需要将以下代码写入您的 checkLogin.php

 <?php 
if(isset($ _ POST ['submit'])){
$ username = mysql_real_escape_string($ _ POST ['username']);
$ password = sha1(mysql_real_escape_string($ _ POST ['password']));
$ result = mysql_query('SELECT id,username FROM users WHERE users.username ='。$ username。'AND users.username =。'$ password)or die('unable to select database');
if(mysql_num_rows($ sesult)> 0){
$ row = mysql_fetch_array($ result);
$ _SESSION ['userId'] = $ row ['userId'];
}
}
?>

在其他页面中,如果你想检查用户是否记录,那么你只需要检查会话变量

  if(isset($ _ SESSION ['userId'])){
//给页面访问此用户。
}

这只是一个关于PHP工作原理的基本概念,开始我会推荐你​​看看本教程为新手。
http://devzone.zend.com/article/627


I'm an iPhone developer who's new to web development. I'm experienced HTML and CSS, but I'm new to PHP, and installed MAMP on my mac.

I'm writing a website for someone who needs a basic CMS (I think that's the right term!). Basic info that they will need to edit such as home page text, about section, etc. I have set up as php includes on txt files. Like this (on the home page):

<?php include 'homeText.txt' ?>

I've also setup an admin.php page where admins can login to edit the site's content. (When I say login I mean if (username == x && password == x) with hardcoded values).

In this page I'd like to have a drop-down, allowing the user to select a text file to open, and when they choose one, it opens up in a rich text editor. (Any formatting would be HTML, which the rich editor would parse, to show formatted text).

Does anyone know of a suitable, open-source rich HTML editor that I could easily embed into a PHP page, and send the resulting HTML off on a PHP post to write to the file?

Thanks in advance - sorry for asking such a beginner question!

解决方案

you are doing it wrong way, i highly doubt that you can develop the application so sooner, as you said you only started learning PHP from yesterday, your examples shows that you are very poor in understating the basics of server side language, you said you would check the login with if (username == x && password == x) this is totally wrong way of doing it, instead you should use database like MySQL to store and check the login credentials i.e via $_SESSION (Session Variable), to be more precise,

Consider a Login Form

<form action="checkLogin.php" method="post">
    <input type = "text" name="username"/>
    <input type = "password" name = "password"/>
    <input type = "submit" name = "submit" value ="login"/>
</form>

It is always better to have database, consider the following database with the following tables and values.

CREATE TABLE `users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) NOT NULL,
  `password` varchar(50) NOT NULL,
  PRIMARY KEY (`id`),
);
INSERT INTO `users` VALUES('First User', '6c049bc0f30da673d0a82c5bd1a13cde');
INSERT INTO `users` VALUES('Second User', '6a6150f8eb2c263a31eb91487bebf1d6');
INSERT INTO `users` VALUES('Third User', '2fd7e7348da8dd5f67103b15be525859');

the second argument is hashed values of your password, i have used md5(), you can use sha1() or others too.

Now to check the login credentials you need to write the following code in your checkLogin.php

<?php
if(isset($_POST['submit'])) {
    $username = mysql_real_escape_string($_POST['username']);
    $password = sha1(mysql_real_escape_string($_POST['password']));
    $result = mysql_query('SELECT id, username FROM users WHERE users.username = '.$username.' AND users.username =.'$password) or die('unable to select database');
    if(mysql_num_rows($sesult) > 0) {
        $row = mysql_fetch_array($result);
        $_SESSION['userId'] = $row['userId'];
    }   
}
?>

in other pages if you want to check if the user is logged so that you can give him access, then you simply need to check Session Variables

if(isset($_SESSION['userId'])) {
    //Give Page Access to this user.
}

This is just a basic and rough idea about how PHP works, to get you started i would recommend you check out this tutorial for Novice. http://devzone.zend.com/article/627

这篇关于开源富HTML编辑器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆