I have a simple form , all I want is to submit the form to same page. I have tried reading other answers including
action=""
- wordpress saysOops! That page can’t be found.
action="#"
- wordpress saysOops! That page can’t be found.
action="<?php echo($_SERVER["PHP_SELF"]);?>"
- redirects to/index.php
pageremoving action tag
- wordpress saysOops! That page can’t be found.
But nothing works. What I should do now ?
This is my code
<?php
/*
Plugin Name: Contact Form
Plugin URI: http://wpgeeks.net/
Version: 1.0
Author: Adam
Description: A simple contact form for testing
*/
/*Security Note: Consider blocking direct access to your plugin PHP files by adding the following line at the top of each of them, or be sure to refrain from executing sensitive standalone PHP code before calling any WordPress functions.*/
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
//add_action( 'plugins_loaded', 'functionShowForm' );
function functionShowForm($atts){
$waq_values = shortcode_atts(array(
'color'=>'white'
),esc_html($atts));
?>
<form style="color:<?php echo $waq_values['color'];?>;" method="post" action=" ">
Name: <input type="text" name="waq_name" placeholder="First Name">
Email: <input type="email" name="waq_email" placeholder="[email protected]">
Password:<input type="password" name="waq_password">
<input type="submit" name="waq_submit" value="Submit">
</form>
<?php
}//function ends here
function process_wpse_194468(){
if ($_SERVER['REQUEST_METHOD']=="POST" and isset($_POST["waq_submit"])){
$to = sanitize_email($_POST["waq_email"]);
$subject = esc_html($_POST["waq_name"]);
$message = $_POST["waq_password"];
echo "Email " .$to;
wp_mail( $to, $subject, $message );
}
}
//short code
add_shortcode('showform','functionShowForm');
add_action('init','process_wpse_194468');
?>