html - PHP: Check select value and textbox != NULL -


This may be a silly question, but I've just got brainfreeze.

HTML

  & lt; B & gt; Comment & lt; / B & gt; & Lt; Br> & Lt; Choose name = "text" id = "text" & gt; & Lt; Option value = "" & gt; Choose an option & lt; / Option & gt; & Lt; Option value = "option1" & gt; Option 1 & lt; / Options & gt; & Lt; Option value = "option 2" & gt; Option 2 & lt; / Options & gt; & Lt; Option value = "Other" & gt; Other & lt; / Options & gt; & Lt; / Select & gt; & Lt; Div square = "other box" & gt; & Lt; B & gt; Comment 2 & lt; / B & gt; & Lt; Br> & Lt; Input type = "text" name = "own_text" & gt; & Lt; / Div & gt;  

If a person selects the "Other" value from the selection then I also need to make sure that the text box (own_text) is not with the null, PHP.

Try

  if ($ _ POST ['text'] == "other" & $ _POST ['own_text' ]! = "") {Go 'Go'; } Else {echo 'you chose the other but did not type anything'; }  

With this code I have received the error message (you have selected other but have not typed anything) even if I have chosen "option1" or "option2" ? If I have chosen "Option 1" or "Option 2", then it will tell me the other message (Go).

Thanks in advance thanks! =) "$" = "Other" = $$ _POST

Solution (thanks Olvथर)

  if ($ _ POST ['text '] = $ "' Own_text '] =" ") {Reverb' Go ';} Else {echo' you chose the other but did not type anything ';}  
< P>

If you are selecting "other" to continue, try it

  if ($ _ POST ['text']! = "Other" || $ _POST ['own_text']! = "") {Echo 'go';} Else {echo 'you chose another but did not type anything';} < / Code> 

Comments