I am trying to do a user registration form in my site's side bar, although users were able to register but instead of getting success message, wordpress usually redirect them to 404 page.
below is my form
<form id="joinmaillist" method='post'>
<table>
<tr>
<td>Name</td>
<td><input type="text" placeholder="Your name here.." name="name" title="Please enter your name" required/></td>
</tr>
<tr>
<td>Email</td>
<td><input type="email" name="email" placeholder="Your email here.." required/></td>
</tr>
<tr>
<td></td>
<td style="text-align:right"><input class="submitmail" type="submit" value="Join!" name="joinm"/></td>
</tr>
</table>
</form>
and below is my php code
<?php
if (isset($_POST['joinm'])){
$user_name=$_POST['name'];
$email =$_POST['email'];
$user_id= username_exists($user_name);
if (!$user_id){
$random_pass = wp_generate_password(12, false);
$user_id=wp_create_user($user_name, $password, $email);
header('Location:' . $_SERVER['REQUEST_URI']);
}else{
}
}