mysql db に情報を送信するフォームがあります。エラー メッセージと確認はフォームの右側の別の div に表示されるため、フォーム アクションはユーザーを同じページに送る必要があります。表示されるエラー メッセージに基づいて何かを編集する必要がある場合に備えて、ユーザーが入力したフィールドをエコーしています。ただし、フォームが正しく送信された場合、php がフォームにエコーしないようにするにはどうすればよいですか?
<?php
$submit = filter_input(INPUT_POST, 'submit');
//form data
$fullname = filter_input(INPUT_POST, 'fullname');
$email = filter_input(INPUT_POST, 'email');
$business = filter_input(INPUT_POST, 'business');
$date = date("Y-m-d");
?>
次に、他のhtmlコードの後に....
<div class="wrap">
<div id="reg">
<form action='register.php' method='POST'>
<table>
<tr>
<td>
Your full name:
</td>
<td>
<input type='text' name='fullname' value='<?php echo $fullname;?>'>
}
</td>
</tr>
<tr>
<td>
Your email:
</td>
<td>
<input type='text' name='email' value='<?php echo $email;?>'>
</td>
</tr>
<tr>
<td>
Your business:
</td>
<td>
<input type='text' name='business' value='<?php echo $business;?>'>
</td>
</tr>
</table>
</br>
<input type='submit' name='submit' value='Register'>
</form>
</br>
</div>
<?php
if ($submit)
{
//open database
$connect=mysql_connect("localhost","root","Ryweb1994");
mysql_select_db("phapsy");
//check for existence
if($fullname&&$business&&$business)
{
$queryreg = mysql_query("INSERT INTO users VALUES ('','$fullname','$email','$business','$date')");
echo ("<div id='message'><p>You have been registered! We will send you an email with login information. Thank you for your interest in Phapsy!<p></div>");
}
else echo "Please fill in <b>all</b> fields!";
}
?>
</div>
</div>