我有文本区域。当我单击提交时,textarea的值插入到db中。然后我有一个按钮。单击按钮后,我转到了保存该texarea值的页面。链接将类似于site.com/index.php?id=1。并在此页面上显示您保存的textarea值
<?php
include 'db.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Php practice</title>
</head>
<body>
<?php
if(isset($_POST['submit']))
{
$textareaValue = trim($_POST['content']);
$sql = "insert into textarea_value (textarea_content) values ('".$textareaValue."')";
$rs = mysqli_query($conn, $sql);
$affectedRows = mysqli_affected_rows($conn);
if($affectedRows == 1)
{
$successMsg = "Record has been saved successfully";
}
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
<label>Textarea:</label>
<div>
<textarea rows="10" cols="60" name="content" required><?php
$_GET['textareaValue'];
?></textarea>
</div>
<input type="submit" name="submit" value="Submit">
</form>
<?php
$giv = "SELECT `id` FROM `textarea_value` WHERE `textarea_content` = '$textareaValue'";
$result = mysqli_query($conn, $giv);
$row = mysqli_fetch_assoc($result);
$id = $row['id'];
?>
<?php
if(isset($_GET['id'])){
$id = $_GET['id'];
echo $id;
} else {
echo "failed";
}
?>
<a href="index.php?id=<?php $id; ?>">Go</a>
</body>
</html>
答案 0 :(得分:0)
如果这是您的问题所在
<textarea rows="10" cols="60" name="content" required><?php
$_GET['textareaValue'];
?></textarea>"
正义:
<textarea rows="10" cols="60" name="content" required>
<?php
echo /*<<<here*/ $_GET['textareaValue'];
?>
</textarea>
如果这不是您要查找的内容,请尝试使其更加清晰。