Form in plugin redirects to 404 page
-
Hey, I’m writing a plugin that has a shortcode that displays a form. But when I submit the form it redirects to the 404.php page. What am I doing wrong?
Here is my code:
function ShowAddTestimonialForm() { global $wpdb; require_once('recaptchalib.php'); $publicKey = '6LevfbwSAAAAAI-IQCL4v1EFEA6KIZbI7g4uDpkq'; $privateKey = '6LevfbwSAAAAAHFqkdyJqsXR5aPU_-085X6njYVk'; if (isset($_POST['submit'])) { if (!empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['testimonial'])) { $resp = recaptcha_check_answer($privatekey, $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']); if ($resp->is_valid) { $dataToInsert = array( 'Name' => $_POST['name'], 'Email' => $_POST['email'], 'Testimonial' => $_POST['testimonial'], ); $wpdb->insert(WP_TESTIMONIAL_TABLE, $dataToInsert); $success = "<p style='text-align:center;'>Thank you for adding your testimonial!</p>"; } else { $error = "The code you entered is not correct. Please try again."; } } else { $error = "Please make sure all required fields are not left blank"; } } ?> <?php if (!empty($success)) { echo $success; } else { ?> <form name="testimonialForm" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>"> <p style="text-align:center;"><strong>All fields with an asterisk (*) indicate a required field.</strong></p> <p style="text-align:center; color:red"><strong><?php echo $error; ?></strong></p> <table> <tr> <td><label for="name">Name (*):</label></td> <td><input type="text" size="20" id="name" name="name" required></td> </tr> <tr> <td><label for="email">Email: (*)</label></td> <td><input type="email" size="20" id="email" name="email" required></td> </tr> <tr> <td><label for="testimonial">Testimonial (*):</label></td> <td><textarea id="testimonial" name="testimonial" rows="5" cols="30"></textarea></td> </tr> </table> <div style="clear: both; height: 1px;"> </div> <?php echo recaptcha_get_html($publicKey); ?> <input type="submit" name="submit" value="Submit" /> </form> <?php } ?> <?php }
Can anyone help? Thanks!
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Form in plugin redirects to 404 page’ is closed to new replies.