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 關注
- 214 瀏覽
添加回答
舉報