Cannot modify header
-
I have a contact form that each time I refresh the page I get a prompt to resend all the data, I have added a header(“location: location.php”); to the bottom of the form function to try and prevent this. However all I get is a Cannot Modify Header Information – Headers already sent error. Here is my code
<?php /* Template Name: form-test.php */ include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); include_once(ABSPATH. 'wp-content/themes/fiftyfityNew/contact-form.php'); get_header(); ?> <script> var i=0; function test(){ for(i=0;i<=5;i++){ document.write( "the number is" + i); } } </script> <script> test(); </script> <?php function make_user_feedback_form() { global $wpdb; global $current_user; $ufUserID = $current_user->ID; if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'updateFeedback' ) { $ufDataUpdate = $wpdb->insert( 'wp_user_feedback', array( 'date' => current_time('mysql'), 'responses' => $_POST["test"]) ); } }?> <div id="form"> <ol> <form method="post"> <li><label for="test">Pick a date Babe:</label><input type="text" id="datepicker" name="test" value="" /></li> <!-- the (name="test") value is what the ('responses' => $_POST["test"]) value is talking too --> <li><input name="submit" type="submit" id="submit" class="submit button" value="Send feedback" /></li> <?php wp_nonce_field( 'updateFeedback' ); ?> <input name="action" type="hidden" id="action" value="updateFeedback" /> </form> </ol> </div> <?php add_action('the_content','make_user_feedback_form'); header("location: http://localhost:8888/fiftyfity/?page_id=90"); ?> <?php make_user_feedback_form(); ?> <?php get_sidebar(); ?> <?php get_footer(); ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Cannot modify header’ is closed to new replies.