我怎么觉得大家都没仔细看楼主的贴呢?楼主是要提交到1.php,1.php包括一个iframe,然后iframe里面有2.php,然后让2.php刷新,是这意思吧?PleaseDoTellMeWhy 星星很多,不过好像说的是怎么直接提交到2.php吧?Mistruster 方法应该是可行的,如果去掉header("Location: 2.php");这句话的话,不过直接改写php内容。那干嘛不用html静态文件呢?改程序内容总是不安全的做法了我觉得大家不要误导楼主啊,楼主不就是不想用数据库么?用Session不就行了?给楼主看看php手册里关于session的介绍: session_start (PHP 4, PHP 5)session_start -- Initialize session data Description bool session_start ( void ) session_start() creates a session or resumes the current one based on the current session id that's being passed via a request, such as GET, POST, or a cookie. This function always returns TRUE. 注: If you are using cookie-based sessions, you must call session_start() before anything is outputted to the browser. 例子 1. A session example: page1.php<?php // page1.phpsession_start();echo 'Welcome to page #1';$_SESSION['favcolor'] = 'green'; $_SESSION['animal'] = 'cat'; $_SESSION['time'] = time();// Works if session cookie was accepted echo '<br /><a href="page2.php">page 2</a>';// Or maybe pass along the session id, if needed echo '<br /><a href="page2.php?' . SID . '">page 2</a>'; ?>
After viewing page1.php, the second page page2.php will magically contain the session data. Read the session reference for information on propagating session ids as it, for example, explains what the constant SID is all about. 例子 2. A session example: page2.php<?php // page2.phpsession_start();echo 'Welcome to page #2<br />';echo $_SESSION['favcolor']; // green echo $_SESSION['animal']; // cat echo date('Y m d H:i:s', $_SESSION['time']);// You may want to use SID here, like we did in page1.php echo '<br /><a href="page1.php">page 1</a>'; ?>
If you want to use a named session, you must call session_name() before calling session_start(). session_start() will register internal output handler for URL rewriting when trans-sid is enabled. If a user uses ob_gzhandler or like with ob_start(), the order of output handler is important for proper output. For example, user must register ob_gzhandler before session start. 注: Use of zlib.output_compression is recommended rather than ob_gzhandler() 注: As of PHP 4.3.3, calling session_start() while the session has already been started will result in an error of level E_NOTICE. Also, the second session start will simply be ignored. See also $_SESSION, session.auto_start, and session_id().
JavaScript的没时间弄了,见谅!index.html
________________________________________________________________________________________________
<iframe name="testframe" width="100%" height="100" marginwidth="0" marginheight="0" frameborder="0" src="about:blank"></iframe><form name="test" action="test.php" method="post" target="testframe">
<textarea name="testarea" cols="100" rows="10"></textarea>
<input type="submit" value="提交" />
</form>test.php
________________________________________________________________________________________________
<?phpif( $_POST['testarea'] )
{
print( $_POST['testarea'] );
}
$_POST['testarea']
改为
nl2br( $_POST['testarea'] )
这个能实现了,但现在遇到的问题是,比如我如果输入
<a href="1.asp">链接</a>实际写到 2.php中的,却是 <a href=\"1.asp\">a</a>只要有"引号就会出问题,请问有什么办法取消这个引号的问题呢?
session_start
(PHP 4, PHP 5)session_start -- Initialize session data
Description
bool session_start ( void )
session_start() creates a session or resumes the current one based on the current session id that's being passed via a request, such as GET, POST, or a cookie. This function always returns TRUE. 注: If you are using cookie-based sessions, you must call session_start() before anything is outputted to the browser. 例子 1. A session example: page1.php<?php
// page1.phpsession_start();echo 'Welcome to page #1';$_SESSION['favcolor'] = 'green';
$_SESSION['animal'] = 'cat';
$_SESSION['time'] = time();// Works if session cookie was accepted
echo '<br /><a href="page2.php">page 2</a>';// Or maybe pass along the session id, if needed
echo '<br /><a href="page2.php?' . SID . '">page 2</a>';
?>
After viewing page1.php, the second page page2.php will magically contain the session data. Read the session reference for information on propagating session ids as it, for example, explains what the constant SID is all about. 例子 2. A session example: page2.php<?php
// page2.phpsession_start();echo 'Welcome to page #2<br />';echo $_SESSION['favcolor']; // green
echo $_SESSION['animal']; // cat
echo date('Y m d H:i:s', $_SESSION['time']);// You may want to use SID here, like we did in page1.php
echo '<br /><a href="page1.php">page 1</a>';
?>
If you want to use a named session, you must call session_name() before calling session_start(). session_start() will register internal output handler for URL rewriting when trans-sid is enabled. If a user uses ob_gzhandler or like with ob_start(), the order of output handler is important for proper output. For example, user must register ob_gzhandler before session start. 注: Use of zlib.output_compression is recommended rather than ob_gzhandler() 注: As of PHP 4.3.3, calling session_start() while the session has already been started will result in an error of level E_NOTICE. Also, the second session start will simply be ignored. See also $_SESSION, session.auto_start, and session_id().
同样还是可以写入,读出的,我现在想解决上面这个问题
比如我如果输入
<a href="1.asp"> 链接 </a>实际写到 2.html 中的,却是 <a href=\"1.asp\"> a </a>只要有"引号就会出问题,请问怎么在确保输入有引号的状态下,不会有\这个在里面呢?
谢谢
fputs($fp, str_replace('\\"','"',$_POST["content"]));不过你真的不应该那样做,你不想使用数据库,有很多办法,比如可以在1.php中使用fopen,然后把你想要保存的数据放在一个array或者class里面,然后使用serialize函数把数组或类转换成字符串后之后,写入data.txt,然后再在2.php中使用unserialize把字符串转换回来,变成数组以后再使用。想你那样为了显示改写整个文件是非常不灵活,也非常容易出错的代码。
stripslashes