我正在从数据库中打印出文本,并且不断收到\r\n,但我不完全确定为什么。这就是我的代码的样子
form action="portal.php" method="post" class="label-top">
<div>
<label for="name">News Message</span></label>
<form method="post" action="" name="bio">
<textarea name="bio" cols="25" rows="5">
<?php echo stripslashes($_SESSION['bio']) ?>
</textarea><br>
我正在尝试使用stripslashes,但它不起作用
我希望我的文字像这样打印出来
Test
Test
但相反,它是这样的
Test\r\nTest
编辑
在关注你们之后,一切似乎都很好,直到我发布它。我认为我的 POST 方法有问题
如果有人有时间去看看这个,那将不胜感激。
<?php
include("mysql_connect.php");
session_start();
if( $_SESSION['login'] != 1 ) {
header( 'Location:login.php' ) ;}
if($_SERVER['REQUEST_METHOD'] == 'POST') {
$bio = mysql_real_escape_string($_POST['bio']);
$user_input = mysql_query("UPDATE members SET bio ='$bio' WHERE username='$_SESSION[username]' ");
$_SESSION['bio'] = $bio;
}
if($_SERVER['REQUEST_METHOD'] == 'POST2') {
$bio = mysql_real_escape_string($_POST['notification']);
$user_input = mysql_query("UPDATE members SET notification ='$notification' WHERE username='$_SESSION[username]' ");
$_SESSION['notification'] = $notifiation;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">
<title>APPSTARME</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<header>
<div class="logo">
<a href="login.php">
<img src="images/logo.png" alt="APPSTARME" />
</a>
</div>
<div class="clear"></div>
</header>
<div class="content">
<article>
<h2 class="underline">Logged in as <?php echo ucfirst($_SESSION['username']); ?> </span></h2>
<form action="portal.php" method="post" class="label-top">
<div>
<label for="name">News Message</span></label>
<form method="post" action="" name="bio">
<textarea name="bio" cols="25" rows="5">
<?php
echo nl2br($_SESSION['bio']); ?>
</textarea><br>
<input type="submit" value="Update Message" /></form>
</div>