How to display $wpdb->insert_id; value on redirected page
-
I have created two pages Checkout Page & Payment Page.
On Checkout Page I added following code:
<?php if(isset($_POST['submit_now'])) { global $wpdb; $wpdb->insert( 'wp9c_treetweet', array( 'name' => $_POST['aname'], 'roll' => $_POST['aroll'] ), array( '%s', '%d' ) ); $lastid = $wpdb->insert_id; wp_redirect( home_url( '/payment/' ) ); exit; } ?> <?php get_header(); ?> <form action="" method="POST" id="addcourse"> <label>Student Name:<input type="text" name="aname" size="30"></label> <label>Roll:<input type="text" name="aroll" size="30"></label> <input type="hidden" name="insert" value="<?php echo $_SESSION[$lastid]; ?>"> <input type="submit" name="submit_now" id="addcoursesubmit" value="Submit"> </form>
And on Payment Page I have added following code:
<?php echo $_SESSION['aname']; ?> <?php echo $_SESSION['aroll']; ?> <?php echo $_SESSION['insert']; ?>
After subbmiting the form the values of Name and Roll is getting displayed on the Payment page but the value of ‘insert’ i.e.
$wpdb->insert_id;
is not getting displayed.Plz help me out with a solution. Thanks.
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘How to display $wpdb->insert_id; value on redirected page’ is closed to new replies.