作者momogen (MOMO‧小光)
看板PHP
标题[请益] 表单、资料库
时间Wed Mar 19 21:03:06 2008
请问各位大大
我想要把在两格表单里的资料上传到资料库里面
这样对吗?
HTML
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title> test </title>
</head>
<body>
<form name="forml" method="get" action="ch3-7-1.php">
<p>姓名:
<input name="name" type="text" id="name">
</p>
<p>学校:
<input name="school" type="text" id="school">
</p>
<p>
<input type="submit" name="Submit" value="送出">
<input type="reset" name="Submit2" value="重设">
</p>
</from>
</body>
</html>
这是ch3-7-1.php
<?php
$link = mysql_connect("■■■", "■■■", "■■■") or die("无法连接资料库
");
mysql_select_db("test") or die("无法选择资料库");
$query = "INSERT INTO test (sch_id, name, score) VALUES ('00001','$name',
'$school')";
mysql_query($query) or die("无法送出" . mysql_error( ));
?>
这样可以成功吗?
能不能直接从资料库看到输入的值?
如果输入很多次 能不能按照顺序让sch_id从00001 > 00002 > 00003 ?
先感谢大大了~
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.134.31.123
※ 编辑: momogen 来自: 220.134.31.123 (03/19 21:17)
1F:推 zhan:不能成功,你php程式没去接收到get发出的资料 03/19 21:33
2F:→ momogen:请问能指导一下该怎麽接收吗 感谢>"< 03/19 21:36
3F:推 del680202:$_GET["name"] 03/19 22:29
4F:→ del680202:sch_id 是主键吗? 可以设自动递增 03/19 22:31
5F:→ momogen:请问什麽是主键..? 自动递增..? 03/19 22:52
7F:→ del680202:如果你有MySQL的GUI的管理介面 这些动作会比较容易做到 03/19 23:10
8F:→ momogen:嗯.. sch_id是主键 但是要怎麽让它自动递增呢? 感谢 03/19 23:19
9F:→ momogen:另外 $school = $_GET ["school"] 这样写对吗? 03/19 23:21
10F:→ momogen:它有跳出错误讯息>"< 03/19 23:22
11F:推 del680202:你可以用phpMyAdmin的"附加"的auto_increment来设定 03/19 23:30
12F:→ del680202:自动递增 03/19 23:32