Link to home
Start Free TrialLog in
Avatar of Hari Shankar
Hari ShankarFlag for India

asked on

Form submission on Wordpress not working ?

Hi Experts,


We have created a customized WordPress signup form in a page template. But when I hit the submission button the form is not submitting and I can't confirm the form submission is working. whenever I echoed back it's not showing. please see the below code


<?php

 /* Template Name:  signup-couple*/
global $current_user;
get_currentuserinfo();

  if (isset($_POST['submit']) {
    # code...
  
echo "am here";
$name = $_POST['name'];
$password = $_POST['password'];
$email = $_POST['email'];
$date = $_POST['date'];

echo $name;

if (($name != '') && ($password != '') && ($email != '')) {
    // TODO: Do more rigorous validation on the submitted data

    // TODO: Generate a better login (or ask the user for it)
    //$login = $firstname . $lastname;

    // TODO: Generate a better password (or ask the user for it)
    //$password = '123';

    // TODO: Ask the user for an e-mail address
    //$email = 'test@example.com';

    // Create the WordPress User object with the basic required information
    $user_id = wp_create_user($name, $password, $email);

    if (!$user_id || is_wp_error($user_id)) {
       // TODO: Display an error message and don't proceed.
      echo "<Script>alert('something went wrong');</script>";
    }

    // $userinfo = array(
    //    'ID' => $user_id,
    //    'date' => $firstname,
    //    'last_name' => $lastname,
    // );

    // Update the WordPress User object with first and last name.
    //wp_update_user($userinfo);

    // Add the company as user metadata
    update_usermeta($user_id, 'date', $date);
}

}

Open in new window


Html Form

 <form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post" >
            
            <!-- Text input-->
            <div class="form-group">
              <label class="control-label" for="name">Your Name<span class="required">*</span></label>
              <input id="name" name="name" type="text" placeholder="Your name" class="form-control input-md" required>
            </div>
            
          <!-- Text input-->
            <div class="form-group">
              <label class="control-label" for="email">Password<span class="required">*</span></label>
              <input id="email" name="password" type="password" placeholder="Password" class="form-control input-md" required>
            </div>




            <!-- Text input-->
            <div class="form-group">
              <label class="control-label" for="email">E-mail<span class="required">*</span></label>
              <input id="email" name="email" type="text" placeholder="E-Mail" class="form-control input-md" required>
            </div>
            
             <!-- Select Basic -->
            <div class="form-group">
            <label class="control-label" for="phone">Wedding Date<span class="required">*</span></label>
             
               <input type="text" name="date" placeholder="Wedding Date" id="datepicker" class="form-control" required>
              
            </div>
           <!-- Button -->
            <div class="form-group">
              <button id="submit" name="submit" value="submit" class="btn btn-primary">Create An Account</button>
            </div>
          </form>

Open in new window

SOLUTION
Avatar of zephyr_hex (Megan)
zephyr_hex (Megan)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Hari Shankar

ASKER

Hi Megan ,

Its not working i changed the Button type to submit . Whenever i hit submit it shows page not found . Any clue on this .Also found a link on net
http://wordpress.stackexchange.com/questions/11749/why-when-i-submit-a-form-in-wordpress-it-loads-a-404-page-though-url-is-correct

Any name i could change on my form
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Wordpress has the default  keywords . If you are using this on your form it won't work . make sure you dont use it