textbox in html
textbox in html
这是我的代码:
<html>
<body>
<BR><p><U>Add contact...</U></p><BR>
Name: <INPUT TYPE="text" NAME="firstbox">
Id.number: <INPUT TYPE="text" NAME="idbox">
<?php
session_start();
$username=$_SESSION['UserID'];
$s_name=$_GET['firstbox'];
$s_id=$_GET['idbox'];
$db = mysql_connect("???????", "???????", "");
mysql_select_db("???????",$db);
$result = mysql_query("SELECT * FROM contacts WHERE u_id='$username' and c_id='$s_id'",$db);
$myrow = mysql_fetch_row($result);
if(!$myrow) {
mysql_query("INSERT INTO contacts(u_id, c_name, c_id) VALUES ('$username','$s_name','$s_id')",$db);
header("Location: http://?????/protectedpage.php");
} else {
header("Location: http://?????contact1.htm");
}
?>
</body>
</html>
是否可以检查是否在firstbox
和lastbox
中输入了I值,如果是,连接到数据库,但如果否,不插入数据库?
是否有可能限制框中的总整数,例如,在idbox
中,如果整数大于5(12345,11234,99900),则不插入数据库?
好的,我已经试过了,但它不工作
if (($s_id="") and ($_name=""))
{
header("Location: http://at-web2.comp.glam.ac.uk/students/10003088/contact1.htm");
}
else
{
$db = mysql_connect("at-web2.comp.glam.ac.uk", "user_10003088", "Glamorgan1");
mysql_select_db("db_10003088",$db);
$result = mysql_query("SELECT * FROM contacts WHERE u_id='$username' and c_id='$s_id'",$db);
$myrow = mysql_fetch_row($result);
if(!$myrow)
{
mysql_query("INSERT INTO contacts(u_id, c_name, c_id) VALUES ('$username','$s_name','$s_id')",$db);
header("Location: http://at-web2.comp.glam.ac.uk/students/10003088/protectedpage.php");
}
else{
header("Location: http://at-web2.comp.glam.ac.uk/students/10003088/contact1.htm");
}
}
我添加了if语句来检查,
你所有问题的答案都是"是"。
-
要检查文本框是否为空,请为每个文本框添加if语句(使用文本框名称而不是"text":
$firstbox = $_POST['firstbox']; If ($firstbox === "") { Echo "firstbox Empty"; } $idbox = $_POST['idbox']; If ($idbox === "") { Echo "idbox Empty"; }
-
检查idbox的值,使用类似的if语句:
$idbox = $_POST['idbox']; If (intval($idbox) > 5) { Echo "idbox value greater than 5"; }
相关文章:
- write HTML in JavaScript
- lightbox in html 5 and javascript
- jquery in the middle of html
- Escaping/Unescaping html in javascript?
- Scripts.Render in c# class (create html helper).在 c# 文件中使用 H
- limiting only value 0/1 in <td> html
- Writing HTML in JavaScript
- Hidding TextBox in html
- android spinner in html/javascript
- 如何从 javascript in html 访问 Java 中的方法
- 替换从外部 IN for 循环加载的 HTML 字符串中的字符
- Java Script: onsubmit=“check_rfields();” in form tag of html
- How append html in a <div>
- jQuery change html in $(this) object
- HTML In Page 在使用 AJAX 更改内部 HTML 后恢复为原始 HTML
- Html in jquery string
- 不能使用node js server访问html in的内容
- dynamic html in js with angularJS
- HTML in Chart.js labels
- angular js ng html in ng repeat won'不起作用