3 回答
TA贡献1803条经验 获得超3个赞
我认为你需要这样做
<form action='addnewthread.php' method='post'>
<input type='text' name='thread-title' id='thread-title' placeholder='Type title here' class='user-input'
<?php
if(isset($_SESSION['threadTitle']) && !empty($_SESSION['threadTitle']))
{
echo "value='{$_SESSION['threadTitle']}'";
}
?>
>
<textarea id='threadCont' name='threadCont'>
<?php
if(isset($_SESSION['threadCont']) && !empty($_SESSION['threadCont']))
{
echo $_SESSION['threadCont'];
}
?>
</textarea>
<button id='submit' type='submit' name='submit'value='success'>Submit</button>
</form>
TA贡献1995条经验 获得超2个赞
只需回显变量,只需注意"and'因为字符串连接。
对于输入:
<input type='text' name='thread-title' id='thread-title' placeholder='Type title here' class='user-input'
<?php
if(isset($_SESSION['threadTitle'])&!empty($_SESSION['threadTitle'])
{
echo "value='".$_SESSION['threadTitle']."'";
}
?>
/>
对于文本区域:
<textarea id='threadCont' name='threadCont'>
<?php
if(isset($_SESSION['threadCont'])&!empty($_SESSION['threadCont'])
{
echo $_SESSION['threadTitle'];
}
?>
</textarea>
TA贡献1801条经验 获得超16个赞
我检查了您的代码,发现您忘记添加圆括号:
<form action='addnewthread.php' method='post'>
<input type='text' name='thread-title' id='thread-title' placeholder='Type title here' class='user-input'
<?php
if(isset($_SESSION['threadTitle'])&&!empty($_SESSION['threadTitle']) <--here
{
echo "value='{$_SESSION['threadTitle']}'";
}
?>
>
<textarea id='threadCont' name='threadCont'>
<?php
if(isset($_SESSION['threadCont'])&&!empty($_SESSION['threadCont']) <--and here
{
echo $_SESSION['threadCont'];
}
?>
</textarea>
<button id='submit' type='submit' name='submit'value='success'>Submit</button>
</form>
您还需要替换&为&&.
- 3 回答
- 0 关注
- 176 浏览
添加回答
举报