如何在输入文本类型中提交默认值? [英] How to submit a default value in an input text type?

查看:90
本文介绍了如何在输入文本类型中提交默认值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是一个名为add_total()的函数;我用它来保存键入的输入字段用户ID,名称,总数和日期在表单中保存在我的数据库中并100%工作。



但我怎么能在输入字段中保存值是默认值,例如value =1500和value =<?php echo $ _GET ['total']?>到我的数据库?



Below is a function called add_total(); which i use to save typed input fields user id, name, total and date in a form to save them in my database and works 100%.

but how can i save values in a input field which are default values such as value="1500" and value="<?php echo $_GET['total'] ?>" to my database?

<input  type="text" value="1500" name="total" >







<input  type="text" value="<?php echo $_GET['total'] ?>" name="total" >





每次我提交这样的输入字段我的数据库记录0.请帮忙!顺便说一句,我还是php html和javascript的新手。



我尝试了什么:



函数Add_total()

{



$ user_id = $ _POST ['user_id'];

$ name = $ _POST ['name'];

$ total = $ _POST ['total'];

$ date = date(' Ymd h:i:s');



$ sql = sprintf(INSERT INTO`user`(`user_id`,`name`,`total`,` status`,`date`)VALUES('$ user_id','$ name','$ total','0','$ date'));



$ rs = mysqli_query($ this-> connection_to_database,$ sql)或死(mysqli_error());

返回true;

返回false;

}< / pre>



every time i submit such input fields my database records 0. please help! and by the way i am still new to php html and javascript.

What I have tried:

function Add_total()
{

$user_id = $_POST['user_id'];
$name = $_POST['name'];
$total = $_POST['total'];
$date = date('Y-m-d h:i:s');

$sql=sprintf("INSERT INTO `users`(`user_id`, `name`, `total`, `status`, `date`) VALUES ('$user_id','$name','$total','0','$date')");

$rs=mysqli_query($this->connection_to_database,$sql) or die(mysqli_error());
return true;
return false;
}</pre>

推荐答案

_GET ['total']?>到我的数据库?



_GET['total'] ?>" to my database?

<input  type="text" value="1500" name="total" >







<input  type="text" value="<?php echo


_GET ['total']?> name = total >
_GET['total'] ?>" name="total" >





每当我提交此类输入字段时,我的数据库记录为0.请帮忙!顺便说一句,我还是php html和javascript的新手。



我尝试了什么:



函数Add_total()

{




every time i submit such input fields my database records 0. please help! and by the way i am still new to php html and javascript.

What I have tried:

function Add_total()
{


user_id =
user_id =


这篇关于如何在输入文本类型中提交默认值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆