0

Im trying to get a " date " field on my form, but the field must be hidden, and will insert into the database upon successful registration. The Date field will get the current Date.

<form action="" method="post" name="join_form" class="form-horizontal" role="form" enctype="multipart/form-data" onSubmit="return checkform(this);">
<div class="form-group ">
<label for="join_email" class="col-md-1 control-label"><span class="required">*</span>Server Title</label>
<div class="col-md-5">
  <input name="name" value="<?php if (isset($_POST['name'])) echo $_POST['name']; ?>" class="form-control" placeholder="Example Scape" required>
</div>
</div>
<div class="form-group ">
<label for="join_password" class="col-md-1 control-label"><span class="required">*</span>Website URL</label>
<div class="col-md-5">
<input name="url" value="<?php if (isset($_POST['url'])) echo $_POST['url']; ?>" class="form-control" placeholder="http://yourdomain.com" required>
</div>
</div>
<div class="form-group ">
<label for="join_url" class="col-md-1 control-label"><span class="required">*</span>Banner URL</label>
<div class="col-md-5">
<input name="banner" value="<?php if (isset($_POST['banner'])) echo $_POST['banner']; ?>" class="form-control" type="text" placeholder="http://example.com/example.png" required>
</div>
</div>
<div class="form-group ">
<label for="join_title" class="col-md-1 control-label"></label>
<div class="col-md-5"></div>
</div>
<div class="form-group ">
<label for="join_description" class="col-md-1 control-label"><span class="required">*</span>Description</label>
<div class="col-md-5">
<textarea cols="50" rows="5" value="<?php if(isset($_POST['description'])) echo $_POST['description']; ?>" name="description" id="description_size" class="form-control" placeholder="Short description, rates, features, etc..." required></textarea>
</div>
</div>
<input type="submit" name="submit" value="Add" />
<input type="hidden" name="submitted" value="TRUE" />
</form>
KIXEYE
  • 21
  • 6
  • 1
    why you want to store it in hidden field, at the time you are saving data, you can generate new date like `date('Y-m-d')` – kamal pal Jun 06 '15 at 20:13
  • Instead of trying to pass the date from the form, why not set the database date field to have a default value of the current date. Then when you insert your data the date will be correct with no hassle. – bassxzero Jun 06 '15 at 20:14
  • How would i go about doing that? – KIXEYE Jun 06 '15 at 20:17
  • http://stackoverflow.com/questions/19246309/mysql-insert-current-date-time – bassxzero Jun 06 '15 at 20:18
  • much appreciated, if you edit your comment to an answer i will mark it as answered thanks. @ bass – KIXEYE Jun 06 '15 at 20:27

1 Answers1

0

In php you could echo the date in a hidden field.

 <input type="hidden" name="date" value="<?php date() ?>">

You can see date function here http://php.net/manual/en/function.date.php

I would advise actually putting the date in on your insert MySQL statement using the following...

date('Y-m-d')
Matt The Ninja
  • 2,641
  • 4
  • 28
  • 58