PHP: How to make the user stay on the same page if the required fields in the form aren't filled? -


If the form is not filled in the required fields, how can I create the user on the same page? Any answers would be greatly appreciated.

  & lt ;? Php header ('location: SOING.html'); $ Name = $ _POST ['name']; $ Nickname = $ _POST ['last_name']; $ Cons = $ _POST ['cons']; $ Password = $ _POST ['pass']; $ Email = $ _POST ['email']; $ Message = $ _POST ['message']; $ Recipient = "pixiedustmed@yahoo.com"; $ '=' Pixiedustmed@yahoo.com '; $ Theme = "contact message: $ name $ surname - $ email"; $ Headers = "to: $ name $ surname \ r \ n"; $ Headers = "Reply:" Strip_tag ($ _ POST ['email']) "\ r \ n"; $ Headers = "Cc: avedis@avedis.ga \ r \ n"; $ Headers = "MIME-Version: 1.0 \ r \ n"; $ Headers = "Content-type: text / html; charset = ISO-885 9-1 \ r \ n"; $ Message = '& lt; Html & gt; & Lt; Body & gt; '; $ Message = '& Lt; div class = "about-center" & gt; & Lt; h1 style = "font-family: Lato-Light; font-size: 2em" & gt; You have received a contact message from your website. & Lt; / H1> & Lt; / Div & gt; '; $ Message = '& Lt; Table rule = "all" style = "border-color: # 666; font-family: Segoyi UI; font-size: 16px;" cellpadding = "12" & gt; '; $ Message = "& lt; tr style = 'background: #b,' & gt; & gt; td & gt; & lt; p style = 'color: # 2c3e50; font-weight: bold' & gt; name: A & lt; / p & gt; & lt; / td> gt; & lt; td & gt; Strip_tag ($ _ POST ['name']) "& lt; / td> gt; & lt; / tr & gt;"; $ Message = "& lt; tr style = 'background: #b,' & gt; & lt; td & gt; & lt; p style = 'color: # 2c3e50; font-weight: bold' & gt; surname: A & lt; / p & gt; & lt; / td> gt; & lt; td & gt; Strip_tag ($ _ POST ['last_name']) "& lt; / td> gt; & lt; / tr & gt;"; $ Message = "& lt; tr & gt; & lt; td & gt; & lt; p Style = 'Color: # 2c3e50; Font-Weight: Bold' & gt; Email: One & lt; / p & gt; & lt ; / td> & lt; td & gt; . Strip_tag ($ _ POST ['email']) "& lt; / td> gt; & lt; / tr & gt;"; $ Message = "& Lt; tr style = 'background: # 71bdf4;' & gt; & lt; TD & gt; & lt; p style = 'Color: #FFFFF' & gt; Message: A & lt; / p & gt; & lt; / TD & gt; & lt; TD & gt; ; ". Strip_tag ($ _ POST ['message']) "& lt; / td> gt; & lt; / tr & gt;"; $ Message = "& Lt; tr style = 'background: # 34495e;' & gt; & lt; TD & gt; & lt; p style = 'Color: #FFFFF' & gt; Counseling information: a & lt; / p & gt; & lt; / td & gt; & lt; td style = 'Color: #FFFFFF' & gt; " Strip_tag ($ _ POST ['cons']) "& lt; / td> gt; & lt; / tr & gt;"; $ Message = "& lt; tr & gt; & lt; td & gt; & lt; p Style = 'Color: # 2c3e50; Font-Weight: bold' & gt; Password: one & lt; / p & gt; & lt; / Td> & lt; td & gt; . Strip_tag ($ _ POST ['pass']) "& lt; / td> gt; & lt; / tr & gt;"; $ Message = "& Lt; / table & gt;"; $ Message = '& Lt; Br> & Lt; h1 style = "font-family: wave-light; font-size: 14px; color: # c0392b;" & Gt; & Lt; A href = "http://avedis.ga" & gt; Click here to open avedis.ga & lt; / A & gt; & Lt; / H1> '; $ Message = '& Lt; h1 style = "font-family: segui UI; font-size: 13px; color: # twenty;" & Gt; This SG Is a self-written message written by & Lt; / H1> '; $ Message = '& Lt; div class = "about-center" & gt; - & lt; / Div & gt; '; $ Message = "& Lt; / body> & lt; / html & gt;"; Mail ($ recipient, $ theme, $ message, $ header, $ password) or die ("Error!"); Echo "thank you!"; ? & Gt;   

So, as you see, I've put the header ('Location: Coming SOON.html'); Besides that which works clearly, in my CSS, I have put in a essential = "" field that did not display a message to the user and click on the submit button. . But now when I have placed a header, then PHP ignores all the things.

My site can be accessed; Scroll down to the end of the page and try in the contact form, and I know what you think about design and all!

  if (empty ($ name) || empty ($ nickname) || empty ( Empty ($ password) || Empty ($ email) || Empty ($ email) || Empty ($ _ POST ['email']) || Empty ($ message) {// Something to do if the field is empty} Other do it after declaring a variable like  $ name ,  $ name ,  $ surname , and do something else  $ Cons .   

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -