嗨,我有这个并且工作正常,除了以下问题。
echo "<form method='post' action=''>";
echo " <input type='text' name='txt1' id='txt1' value=".$_SESSION['txt1'].">";
echo " <input type='submit' name='sendtwo' id='sendtwo' value='TwoClick'>";
echo "</form>";
<A submit button here to send the form data>
问题是如果我在文本框中有一个值,例如John
当我提交表单时,我会在文本框中保留原始用户键入的单词Jonn
。但是,如果用户键入John Carter
,则在提交表单时它只保留John
。换句话说,文本只到文本之间的第一个空格。如何保留整个文本?
编辑
<?php
if(isset($_POST['sendone']))
{
echo "Hello";
echo "<form method='post' action=''>";
echo " <input type='text' name='txt1' id='txt1'>";
echo " <input type='submit' name='sendtwo' id='sendtwo' value='TwoClick'>";
echo "</form>";
}
if(isset($_POST['sendtwo']))
{
if($_POST['txt1']=='')
{
echo "Hello";
echo "<form method='post' action=''>";
echo " <input type='text' name='txt1' id='txt1'>";
echo " <input type='submit' name='sendtwo' id='sendtwo' value='TwoClick'>";
echo "</form>";
echo "Empty";
}
else
{
$_SESSION['txt1'] = $_POST['txt1'];
echo "Hello";
echo "<form method='post' action=''>";
echo " <input type='text' name='txt1' id='txt1' value=".$_SESSION['txt1'].">";
echo " <input type='submit' name='sendtwo' id='sendtwo' value='TwoClick'>";
echo "</form>";
echo "Hit success!";
}
}
?>