PHP SQL 表单验证


PHP SQL Form validations

我正在尝试创建一个在提交之前进行验证的表单。 我的PHP代码是:

<?php
    //include the connection file
    require_once('connection.php');
    require_once("validation.php");
    if( isset($_POST['send']) && (!validateName($_POST['name']) || !validateEmail($_POST['email']) || !validatePasswords($_POST['pass1'], $_POST['pass2']) || !validateContact($_POST['contact']) || !validateAge($_POST['age']) || !validateGender($_POST['gender']) || !validateLocation($_POST['location']) || !validateSkill($_POST['skill']) || !validateWork($_POST['work'])) ):?>
                    <ul>
                        <?php if(!validateName($_POST['name'])):?>
                            <li><strong>Invalid Name:</strong> We want names with more than 3 letters.</li>
                        <?php endif?>
                        <?php if(!validateEmail($_POST['email'])):?>
                            <li><strong>Invalid E-mail:</strong> Type a valid e-mail please.</li>
                        <?php endif?>
                        <?php if(!validatePasswords($_POST['pass1'], $_POST['pass2'])):?>
                            <li><strong>Passwords are invalid:</strong> Passwords doesnt match or are invalid!</li>
                        <?php endif?>
                        <?php if(!validateContact($_POST['contact'])):?>
                            <li><strong>Please enter your contact number.</strong></li>
                        <?php endif?>
                        <?php if(!validateAge($_POST['age'])):?>
                            <li><strong>Please enter your contact number.</strong></li>
                        <?php endif?>
                        <?php if(!validateGender($_POST['gender'])):?>
                            <li><strong>Please enter your contact number.</strong></li>
                        <?php endif?>
                        <?php if(!validateLocation($_POST['location'])):?>
                            <li><strong>Please enter your contact number.</strong></li>
                        <?php endif?>
                        <?php if(!validateSkill($_POST['skill'])):?>
                            <li><strong>Please enter your contact number.</strong></li>
                        <?php endif?>
                        <?php if(!validateWork($_POST['work'])):?>
                            <li><strong>Please enter your contact number.</strong></li>
                        <?php endif?>
                    </ul>
                </div>
            <?php elseif(isset($_POST['send'])):?>
                <div id="error" class="valid">
                    <ul>
                    <?php $query = "INSERT INTO employer (name, password, email, contact, age, gender, location, skill, work) VALUES ";                           
                    $query .= "('$name', 'md5($password)', '$email','$contact','$age','$gender','$location','$skill','$work')";
                    // run the query
                    mysql_query($query);?>
                        <li><strong>Congratulations!</strong> All fields are OK ;)</li>
                    </ul>
                </div>
        <?php endif?>

但显示错误:致命错误:调用第 7 行/home/sifeiitd/public_html/login1.php 中的未定义函数 validateName()

错误是不言自明的。您正在尝试调用当前上下文中不存在的函数。您确定您的某个包含中有此功能吗?