简体   繁体   中英

WooCommerce Custom Login and Sign Up

I have a custom login and sign up form with email and password fields. How can I use them as a WooCommerce sign in and register form, so when I click on the Sign In button, it displays me all products of the store?

  global $wpdb;
  if($_SERVER["REQUEST_METHOD"] == "POST") {
  $username = $wpdb->escape($_REQUEST['username']);
  $password = $wpdb->escape($_REQUEST['password']);
  $_SESSION['username'] = $username;
  $wpdb->get_results("select * from wp_registration where     Email='$username' AND Password='$password'");
  $count=  $wpdb->num_rows;
   if($count == 1) {  
    echo"<script>alert('Welcome')</script>";
    header('Location:index.php');
   }  
  else {
    echo"<script>alert('Incorrect Username or Password!')</script>";
    }  
   }
   ?>



 <input type="text"  style="font-size: xx-large !important;"  placeholder="Username" onfocus="this.placeholder=''" onblur="this.placeholder = 'Username'" name="username" required>

   <input type="password" style="font-size: xx-large !important;"  placeholder="password" onfocus="this.placeholder=''" onblur="this.placeholder = 'password'" name="password" required>

   <span class="psw"><input type="submit">Submit</span>
if (isset($_POST['signup'])) {
    $username = $_POST['username'];
    $password = $_POST['password'];
    $creds = array();
    $creds['user_login'] = $username;
    $creds['user_password'] = $password;
    $creds['remember'] = false;
    $user = wp_signon($creds, false);
    if (is_wp_error($user)) {
        echo"<script>alert('Incorrect Username or Password!')</script>";
    } else {
        echo"<script>alert('Welcome')</script>";
        header('Location:index.php');
    }
}
?>


<form method="post">
 <input type="text"  style="font-size: xx-large !important;"  placeholder="Username" onfocus="this.placeholder=''" onblur="this.placeholder = 'Username'" name="username" required>

   <input type="password" style="font-size: xx-large !important;"  placeholder="password" onfocus="this.placeholder=''" onblur="this.placeholder = 'password'" name="password" required>

   <span class="psw"><input name="signup" type="submit">Submit</span>
</form>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM