Skip to content

Instantly share code, notes, and snippets.

@azizultex
Created January 9, 2014 07:16
Show Gist options
  • Select an option

  • Save azizultex/8330569 to your computer and use it in GitHub Desktop.

Select an option

Save azizultex/8330569 to your computer and use it in GitHub Desktop.
add_shortcode('multipage_form_sc','multipage_form');
function multipage_form(){
global $wpdb;
$this_page = $_SERVER['REQUEST_URI'];
$page = $_POST['page'];
if ( $page == NULL ) {
echo '<form method="post" action="' . $this_page .'">
<label for="first_name" id="first_name">First Name: </label>
<input type="text" name="first_name" id="first_name" />
<label for="last_name" id="last_name">Last Name: </label>
<input type="text" name="last_name" id="last_name" />
<label for="email" id="email">Email: </label>
<input type="text" name="email" id="email" />
<label for="phone" id="phone">Phone: </label>
<input type="text" name="phone" id="phone" />
<label for="first_name" id="first_name">Zip Code: </label>
<input type="text" name="zip_code" id="zip_code" />
<input type="hidden" value="1" name="page" />
<input type="submit" />
</form>';
}//End Page 1 of Form
elseif ( $page == 1 ) {
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$zip_code = $_POST['zip_code'];
echo '<h3>You made it to the 2nd page!</h3>
<p>Here are your form inputs: </p>
<p>First Name: ' . $first_name . '</p>
<p>Last Name: ' . $last_name . '</p>
<p>Email: ' . $email . '</p>
<p>Phone: ' . $phone . '</p>
<p>Zip Code: ' . $zip_code . '</p>';
}//End Page 2 of Form
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment