php - submit on correctly entered captcha -


I have the following page with an option box, when the user selects the following option and then click on the submit , Then takes them to the corresponding URL, however the user should write the correct string in the box that corresponds to a simple static captcha image which is on the screen.

Currently the code looks like this, although I need help setting this situation so that it should be typed in the "abcdef" box before it is otherwise giving an error.

  & lt ;? Php // Check to see if the form has been submitted. If (isset ($ _ POST ['menu1'])) // If the form is submitted, redirect to the selected option. Header ('location:' $ _POST ['menu1']); }? & Gt; & Lt; Div style = "padding-left: 50px" & gt; & Lt; P class = "ariel" & gt; & Lt; Strong & gt; & Lt; / Strong> gt; & Lt; Br / & gt; & Lt; / P & gt; & Lt; Form method = "post" & gt; & Lt; Table class = "free contact area" range = "0" width = "400px" & gt; & Lt; Tbody & gt; & Lt; TR & gt; & Lt; Td colspan = "2" & gt; & Lt; Span style = "font-size: x-small;" & Gt; & Lt; / Span & gt; & Lt; Font color = # 000000 & gt; & Lt; / Font & gt; & Lt; Br / & gt; & Lt; Br / & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td valign = "top" & gt; & Lt; Table width = "400px" class = "freecontact2form" & gt; & Lt; TR & gt; & Lt; Td colspan = "2" & gt; & Lt; Br / & gt; & Lt; Br / & gt; & Lt; Div class = "freecontact2formmessage" & gt; & Lt; / Div & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td valign = "top" & gt; For label = "menu1" & gt; These are the following options: & lt; Span class = "required_star" & gt; & Lt; / Span & gt; & Lt; / Labels & gt; & Lt; / TD & gt; & Lt; Td valign = "top" & gt; & Lt; Select name = "menu1" id = "menu1" & gt; & Lt; Option selected = "selected" value = "http://www.google.com" & gt; Google & lt; / Options & gt; & Lt; Option value = "www.msn.com" & gt; MSN & lt; / Options & gt; & Lt; Option value = "www.youtube.com" & gt; YouTube & lt; / Options & gt; & Lt; Option value = "bing.com" & gt; Bing & lt; / Options & gt; & Lt; / Select & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td valign = "top" & gt; For label = "Captcha" & gt; & Lt; Span class = "required_star" & gt; & Lt; / Span & gt; & Lt; Span class = "required_star" & gt; & Lt; / Span & gt; & Lt; / Labels & gt; & Lt; / TD & gt; & Lt; Td valign = "top" & gt; & Lt; Br / & gt; & Lt; BR / & gt; & Lt; Img src = "captcha.jpg" /> & Lt; / Td> & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td> Please enter the characters shown in the captcha image: & lt; / Td> & Lt; Td> & Lt; Input type = "text" name = "captcha" id = "captcha" value = "" size = "10" /> & Lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td style = "text-align: center" colspan = "2" & gt; & Lt; Br / & gt; & Lt; Br / & gt; & Lt; Input type = "submit" value = "submit" & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; / Table & gt; & Lt; / TD & gt; & Lt; Td valign = "top" & gt; & Amp; Nbsp; & Lt; / Td> & Lt; / TR & gt; & Lt; TR & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; / TR & gt; & Lt; / Tbody & gt; & Lt; / Table & gt; & Lt; / Form & gt; & Lt; Br / & gt; & Lt; P & gt; & Lt; / P & gt; & Lt; P & gt; & Lt; / P & gt;  

When you display the page for the first time, save the code in session. Then check the post value of the code field against the session variable.

  session_start (); $ _SESSION ['Captcha'] = 'ABCDF';   

On the form submission:

  session_start (); If ($ _ POST ['captcha'] == $ _SESSION ['captcha'] and release ($ _ POST ['menu1'])) {header (); }    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -