access non wordpress php files in underscores theme

I’m trying to create a user sign up form in WordPress theme. I searched allot and found a solution which was using a non WordPress php file to insert into database. I’ve created a file “user-register.PHP” to register users from static page. but some how I cannot access that file getting “Page not found error”. I’m using WordPress underscores theme.

sign up form Code:

Read More
<form id="user_form" name="user_form" method="POST" action="../user-register.php">
<input type="text" placeholder="Your Name" id="user_name" name="user_name">
<input type="email" placeholder="Your Email" id="user_email" name="user_email">
<input type="password" placeholder="Your Password" id="You Password">
<button name="sign-up" id="sign-up">Sing Up</button>
</form>

user-register.php

 $user_name=$_POST['user_name'];
    $user_email=$_POST['user-email'];
    $user_pass=$_POST['user-pass'];

    $con=mysqli_connect('localhost', 'kaizen_it', '', wp_site_user);
    if($con){
        $query='insert into wp_site_user(name,email,password)values(,$user_name,$user_email,$user_pass)';
        mysqli_query($con, $query);
        mysqli_close($con);
        header("Location: http://localhost/wordpress/registered.php");
    }

Any help would be appreciated!

Related posts

1 comment

  1. Since you’re not creating a custom page template for this, your path should be the absolute path to your login file. Assuming this file is in the root of your theme:

    <form id="user_form" name="user_form" method="POST" action="<?php echo get_template_directory_uri() . '/user-register.php'; ?>">
    

    Which will render as:

    <form id="user_form" name="user_form" method="POST" action="http://example.com/wp-content/themes/sometheme/user-register.php'; ?>">
    

    This path will need to change if your login file isn’t in the root of your parent theme.

Comments are closed.