Actually the form below is a registration form, and i only have ' username, email, password and confirm password field' so i want to add another field name job, but keeps getting error.
see the code below;

if (!preg_match("/^[a-zA-Z ]+$/",$name)) {
        $error = true;
        $name_error = "Name must contain only alphabets and space";
    }
    if(!filter_var($email,FILTER_VALIDATE_EMAIL)) {
        $error = true;
        $email_error = "Please Enter Valid Email ID";
    }
    if(strlen($password) < 6) {
        $error = true;
        $password_error = "Password must be minimum of 6 characters";
    }
    if($password != $cpassword) {
        $error = true;
        $cpassword_error = "Password and Confirm Password doesn't match";
    }

    if (!preg_match($job)) {
        $error = true;
        $job_error = "Job area must be specified";
    }
    if (!$error) {
        if(mysqli_query($con, "INSERT INTO users(name,email,password,job) VALUES('" . $name . "', '" . $email . "', '" . md5($password) . "',  '" . $job . "')")) {
            $successmsg = "Successfully Registered! <a href='login.php'>Click here to Login</a>";
        } else {
            $errormsg = "Error in registering...Please try again later!";
        }
    }
Member Avatar for diafol

So you don't see anything wrong with this line...

 if (!preg_match($job)) {

http://php.net/manual/en/function.preg-match.php should tell you you need at least two parameters - the pattern and the subject. You have omitted the pattern.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.