forms - Why isn't PHP sending POST request? -
i try submit form, not send form. if try print post array empty.
here form:
<?php print_r($_post); require('includes/config.php'); require('includes/auth_admin.php'); $title = "new block day"; require ('includes/header.php'); //if form has been submitted process if(isset($_post['submit'])){ if(empty($_post['name'])){ $error[] = 'please enter name.'; } $date = $_post['date']; $result = mysqli_query($con, "select name official_holiday date = $date"); while ($row = mysqli_fetch_assoc($result)) { $check[] = $row; } if(empty($_post['date'])){ $error[] = 'please enter date.'; }elseif(!empty($_post['date'])){ $error[] = 'already block date on day.'; } $new_date = $_post['date']; $new_name = $_post['name']; $query = sprintf("insert official_holiday (name, date) values ('%s', '%s')", mysql_real_escape_string($new_name), mysql_real_escape_string($new_date)); $result = mysqli_query($con, $query); header("location:new_block.php?id=$id&changes=successful"); }else{ //header('0'); //exit; } ?> <div class="container"> <div class="row"> <div class="col-xs-12 col-sm-8 col-md-6 col-sm-offset-2 col-md-offset-3"> <form action="new_block.php" method="post" role="form" > <h3><?php echo $title ?></h3> <p><a href='block_days.php'>back</a></p> <?php if(isset($_get['changes']) && $_get['changes'] = 'successful'){ echo '<h4>changes successful.</h4>'; } ?> <hr> <label for="name">name</label> <div class="form-group"> <input type="text" required name="name" id="name" class="form-control" value="<?php if(isset($error)){ echo $_post['name']; } ?>" tabindex="3"> </div> <div class="form-group"> <label for="datepicker">date</label> <div class="input-group input-append date"> <input type="text" class="form-control" id="datepicker" name="date" placeholder="date" value="<?php if(isset($error)){ echo $_post['date']; } ?>"> <span class="input-group-addon add-on"><span class="glyphicon glyphicon-calendar"> </div> </div> <div class="form-group"> <input type="submit" name="submit" id="name" value="submit" class="btn btn-info btn-block" tabindex="5"> </div> </form> </div> </div> </div> <?php require('includes/footer.php'); ?>
why php not send anything?
edit: added full code, there's not can add this.
please comment redirect first:
// header("location:.."
)
Comments
Post a Comment