php - wordpress redirect is not working via form -


i have created custom form in footer.php , in form action have placed action=" , when submit form data saving not know how come when form submitted comes blog page of link url remain same not know why comes blogpage can anyine me out concern please

<form class="booking-form" method="post" action="<?php the_permalink(); ?>">         <div class="form-group">             <h5>                 name             </h5>             <input type="text" class="form-control" name="name">         </div>          <div class="form-group">             <h5>                 phone             </h5>             <input type="text" class="form-control" name="phone">         </div>          <div class="form-group">             <h5>                 address             </h5>             <textarea class="form-control" name="address"></textarea>         </div>          <div class="form-group">             <h5>                 date             </h5>             <input type="text" class="form-control date_of_event" name="date_of_event" value="">         </div>         <div class="form-group">             <h5>                 type             </h5>             <input type="text" class="form-control type_agent" name="type" value="">         </div>          <button type="submit" name="create_new_event" class="btn btn-block">create event</button>     </form> 

this header.php

global $wpdb;  if(isset($_request['create_new_event'])) {     $data = array(         "name"    => $_request['name'],         "phone"   => $_request['phone'],         "address" => $_request['address'],         "date"    => $_request['date_of_event'],         "type"    => $_request['type'],         "status"  => 'booked'     );      $new  = $wpdb->insert("wp_events", $data);     wp_redirect(get_permalink()); } 

you need exit after redirect.

https://developer.wordpress.org/reference/functions/wp_redirect/

wp_redirect( $url ); exit;


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -