The newbie encountered a small problem in the example of making a message board. could you please help me? I want to make a simple message board. I don't have a database. after all, I just learned it for two days ~
Two pages. one page is an HTML message board.
The PHP page is used to input HTML values and then pass in the PHP page to determine whether the passed values are null or whether the mailbox format is correct.
It is displayed directly if it is correct.
At present, I found that my judgment is not easy to use. I don't know what went wrong.
The code is as follows:
Html interface code:
Message
The PHP interface code is as follows:
$ Mst = $ _ POST ['mstit'];
If (isset ($ mst ))
{
Echo "Enter the message title ";
} Else {
Echo $ mst;
}
$ Msu = $ _ POST ['msuser'];
If (isset ($ msu )){
Echo "enter the user name of the message ";
Exit;
}
If (! Preg_match ("/^ [a-zA-Z] * $/", $ msu )){
Echo "this is not a valid user name, please use letters ";
} Else {
Echo $ msu;
}
$ Maem = $ _ POST ['maeme'];
If (isset ($ mean )){
Echo "enter your email address ";
Exit;
}
If (! Preg_match ("/([\ w \-] + \ @ [\ w \-] + \. [\ w \-] +)/", $ maem )){
Echo "this is not a valid email address ";
} Else {
Echo $ maem;
}
$ Comt = $ _ POST ['comment'];
If (isset ($ comt )){
Echo "Enter the message content ";
} Else {
Echo $ comt;
}
?>
Reply to discussion (solution)
If (isset ($ comt )){//! Isset
Echo "Enter the message content ";
} Else {
Echo $ comt;
If (isset ($ comt )){//! Isset
Echo "Enter the message content ";
} Else {
Echo $ comt;
What does it mean?
All the well-known controls except the unselected re-(single) button in the form will be submitted.
So you use
$ Mst = $ _ POST ['mstit'];
If (isset ($ mst ))
It is incorrect to determine whether name = mstit is null.
1. $ _ POST ['mstit'] always exists, no matter whether there is a value or not
2. a prompt is output only when it is empty. your business logic is reversed.
It can be modified in this way.
$ Mst = $ _ POST ['mstit']; if (empty ($ mst) {echo "Enter the message title" ;}else {echo $ mst ;}