无法将验证码放在现有表单上

时间:2013-04-16 17:11:25

标签: php captcha

我无法将captcha放在我已存在的联系表单中,我不知道为什么,或者我做错了什么。

目前我的大多数验证码都有自己的提交表单,但我需要一个提交到这个表单。例如,我遇到的大多数验证码都是这样的,但是帖子是针对我的脚本所在的其他内容设置的。

如何将有效的验证码放入此表单?

这是我目前拥有的html5联系表格:

<?php
  session_start();

class HomeView extends View {
    protected function displayContent() {
        $html .= '<div id="pageinfo">';
        $html .= '<h2>'.$this -> pageInfo['pageHeading'].'</h2>';
        $html .= '</div>';
            if($_POST['register'] == "Submit") {
            //validate the form
            $vresult = $this -> model -> validateRegisterUser();
            //Check ALL okay
                 if ($vresult['ok'] == true) {
                //Call database 
                            if ($this -> model -> register()) {
                                $htmt .='<div id="space">';
                                $html .='<div id="userreg">';
                                $html .='<p> User registered successfully<p>';
                                $html .='<img src ="optimized/images/joined.jpg" alt="welcome new member"/>';
                                $html .= '<p>Welcome to trading post:'.$_POST['userName'].'</p>';
                                $html .='</div>';
                                $html .='</div>';
                                    } else {

                                $html .='<div id="space">';
                                $html .='<img src ="optimized/images/failed.jpg" alt="failed to create new member"/>';
                                $html .= '<p> User creation failed. Please try again <p>';
                                $html .='</div>';
                            }        
                        return $html;
                }   
            }







            $html .='<form id="signup">';
        $html .='<h1>Sign up now!</h1>';

        $html .='<h2>Fields marked (*) are required</h2>';

        $html .='<fieldset>';
            $html .='<legend>Your details</legend>';

            $html .='<ol>';
                $html .='<li>';
                    $html .='<label for="username">UserName *</label> ';
                    $html .='<input type="text" id="userName" name="userName" value="'.htmlentities(stripcslashes($_POST['userFName'])).'" placeholder="UserName" required />';
                    $html .='<div class="error">'.$vresult['userNameMsg'].'</div>';
                $html .='</li>';

                    $html .='<li>';
                    $html .='<label for="userFName">Firstname *</label> ';
                    $html .='<input type="text" id="userFName1" name="userFName" value="'.htmlentities(stripcslashes($_POST['userFName'])).'" placeholder="UserFName" required />';
                    $html .='<div class="error">'.$vresult['userFNameMsg'].'</div>';
                $html .='</li>';


                        $html .='<li>';
                    $html .='<label for="userLName">Surname *</label> ';
                    $html .='<input type="text" id="userLName" name="userLName" value="'.htmlentities(stripcslashes($_POST['userFName'])).'" placeholder="userLName" required />';
            $html .='<div class="error">'.$vresult['userLNameMsg'].'</div>';

                $html .='</li>';



                $html .='<li>';
                    $html .='<label for="userEmail">Email *</label> ';
                    $html .='<input type="email" id="userEmail" name="userEmail" value="'.htmlentities(stripcslashes($_POST['userEmail'])).'" placeholder="e.g. anything@example.com" title="Please enter a valid email" required />';
                    $html .='<p class="validation01">';
                        $html .='<span class="invalid">Please enter a valid email address e.g. ryan@example.com</span>';
                         $html .='<div class="error">'.$vresult['userEmailMsg'].'</div>';


                    $html .='</p>';
                $html .='</li>';


                        $html .='<li>';
                    $html .='<label for="password">Password *</label> ';
                    $html .='<input type="password" id="userPassword1" name="userPassword" value="'.htmlentities(stripcslashes($_POST['userFName'])).'" placeholder="Password" required />';
          $html .='<div class="error">'.$vresult['userPasswordMsg'].'</div>';

                $html .='</li>';
            $html .='</ol>';




              $html .='<input type="submit" name="register" value="Submit" id="submit-button"/>';
        $html .='</fieldset>';
        $html .='</form>';




        return $html;
    }
}

?>

0 个答案:

没有答案