|
 |
|
ว่าด้วยเรื่องFORMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM ฉบับปรับปรุ่ง 1.01 |
|
 |
|
|
 |
 |
|
<form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
อยากทำให้ form readonly,value"????" ทำไงคับ
ขยายความ
ในบรรทัดที่ 62 ผมต้องการทำแบบ <input name="textfield" type="text" disabled id="textfield" readonly="readonly">
ซึ่งให้formเป็นแบบreadonly="readonly "และมี value = "<?php ........?>"
Code (PHP)
<?php
session_start();
$errmsg = "";
if($_POST) {
include("room.inc.php");
$name = $_POST['name'];
if(empty($name)) {
$errmsg = "กรุณากำหนดชื่อก่อนเข้าห้องสนทนา";
}
else if(has_rudeword($name)) { //ตรวจสอบว่ามีคำหยาบอยู่ในชื่อหรือไม่
$errmsg = "ไม่อนุญาตให้ใช้ชื่อที่ไม่เหมาะสม กรุณาแก้ไข";
}
else {
my_connect(); //เชื่อมต่อกับฐานข้อมูล
//SQL ตรวจสอบว่ามีผู้ใช้ชื่อนั้นอยู่ก่อนแล้วหรือไม่
$sql = "SELECT COUNT(*) FROM chatter WHERE name = '$name';";
$result = mysql_query($sql);
//ไม่อนุญาตให้ใช้ชื่อซ้ำกัน
if(mysql_result($result, 0, 0) > 0) {
$errmsg = "ชื่อ: $name มีผู้ใช้แล้ว กรุณาใช้ชื่อใหม่";
}
else {
$sql = "INSERT INTO chatter VALUES('$name', NOW(), NOW());";
mysql_query($sql);
$sql = "INSERT INTO message VALUES
(0, '### $name', 'เข้าร่วมห้องสนทนา ###', 'red', NOW());";
mysql_query($sql);
$_SESSION['name'] = $_POST['name'];
exit;
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<link rel="stylesheet" href="../css/style.css" />
<style type="text/css">
<!--
.style1 {font-size: 16px}
-->
</style>
</head>
<body>
<?php include("header.inc.html"); ?>
<center>
<form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" >
<br />ชื่อ
<input name="name" type="text" id="name" maxlength="30" />
<input type="submit" name="Submit" value="ตกลง" />
</form>
<font color=red><b><?php echo $errmsg; ?></b></font>
</center>
</body>
</html>
Tag : PHP, MySQL

|
ประวัติการแก้ไข 2011-08-22 00:01:12 2011-08-22 00:09:29 2011-08-22 00:10:38 2011-08-22 03:57:31 2011-08-22 04:02:02 2011-08-22 04:03:04 2011-08-22 04:05:39
|
 |
 |
 |
 |
Date :
2011-08-21 23:58:21 |
By :
yag00za |
View :
1072 |
Reply :
19 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้ามีการจัดอันดับกระทู้งงที่สุดแห่งปี คุณติด top 10 แน่นอน 
|
 |
 |
 |
 |
Date :
2011-08-22 00:18:24 |
By :
ikikkok |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ห้าๆ ก็ผมชอบเว็บนี้อ่า เลยเปนขาประจำไปเลย ผมเคยอุดหนุนซอซด้วยนะ อิอิ
|
 |
 |
 |
 |
Date :
2011-08-22 01:09:33 |
By :
yag00za |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คำถามสุดติงจิงๆ งงกันเปนแถบๆ
|
 |
 |
 |
 |
Date :
2011-08-22 02:29:10 |
By :
ppanchai |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ยังไม่ยอมมา เพิ่มข้อมูล ไปนอนดีกว่า งงจนง่วง 
|
 |
 |
 |
 |
Date :
2011-08-22 02:38:06 |
By :
ikikkok |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2011-08-22 06:06:01 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อืม...งง..จริงด้วย
|
 |
 |
 |
 |
Date :
2011-08-22 08:08:11 |
By :
mangkunzo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมก็ยัง งง รีบมาให้ข้อมูลเพิ่มด้วย
|
 |
 |
 |
 |
Date :
2011-08-22 09:34:31 |
By :
compeng |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เหมือนจะถามเองตอบเองหรือป่าว
|
 |
 |
 |
 |
Date :
2011-08-22 09:39:49 |
By :
Dragons_first |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ง่า ผมขยายความแล้วไง ฉบับปรับปรุ่ง 1.01 ยังงง อยู่หรอคับ
|
 |
 |
 |
 |
Date :
2011-08-22 11:24:25 |
By :
yag00za |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คุณก็ทำได้แล้วนิครับ <input name="textfield" type="text" disabled id="textfield" readonly="readonly"> แค่เอา disable ออกก็น่าจะจบ
|
 |
 |
 |
 |
Date :
2011-08-22 11:38:50 |
By :
ikikkok |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อาตร์มากครับ...การเขียนโค้ดไม่เหมือนชาวบ้าน
|
 |
 |
 |
 |
Date :
2011-08-22 11:48:53 |
By :
teedesign |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แบบนี้รึป่าวครับที่ต้องการ
Code (PHP)
<?php
session_start();
$errmsg = "";
if($_POST) {
include("room.inc.php");
$name = $_POST['name'];
if(empty($name)) {
$errmsg = "กรุณากำหนดชื่อก่อนเข้าห้องสนทนา";
}
else if(has_rudeword($name)) { //ตรวจสอบว่ามีคำหยาบอยู่ในชื่อหรือไม่
$errmsg = "ไม่อนุญาตให้ใช้ชื่อที่ไม่เหมาะสม กรุณาแก้ไข";
}
else {
my_connect(); //เชื่อมต่อกับฐานข้อมูล
//SQL ตรวจสอบว่ามีผู้ใช้ชื่อนั้นอยู่ก่อนแล้วหรือไม่
$sql = "SELECT COUNT(*) FROM chatter WHERE name = '$name';";
$result = mysql_query($sql);
//ไม่อนุญาตให้ใช้ชื่อซ้ำกัน
if(mysql_result($result, 0, 0) > 0) {
$errmsg = "ชื่อ: $name มีผู้ใช้แล้ว กรุณาใช้ชื่อใหม่";
}
else {
$sql = "INSERT INTO chatter VALUES('$name', NOW(), NOW());";
mysql_query($sql);
$sql = "INSERT INTO message VALUES
(0, '### $name', 'เข้าร่วมห้องสนทนา ###', 'red', NOW());";
mysql_query($sql);
$_SESSION['name'] = $_POST['name'];
exit;
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<link rel="stylesheet" href="../css/style.css" />
<style type="text/css">
<!--
.style1 {font-size: 16px}
-->
</style>
</head>
<body>
<?php include("header.inc.html"); ?>
<center>
<form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" >
<br />ชื่อ
<input name="name" type="text" id="name" maxlength="30" readonly="readonly" value="<?php echo $values;?>"/> //readonly และก็ value="<?php echo $...;?>" ใส่ตัวแปรเอาเองนะครับ
<input type="submit" name="Submit" value="ตกลง" />
</form>
<font color=red><b><?php echo $errmsg; ?></b></font>
</center>
</body>
</html>
|
 |
 |
 |
 |
Date :
2011-08-22 13:19:39 |
By :
arm8957 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถึงไหนกันแล้ว
|
 |
 |
 |
 |
Date :
2011-08-22 13:38:34 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ก็ยังงงอยู่ดี
|
 |
 |
 |
 |
Date :
2011-08-23 08:51:14 |
By :
Dragons_first |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
555+ คือเค้าอยากได้แค่ตรง text field ให้แสดงค่าได้อย่างเดียวครับ แก้ไขไม่ได้
|
 |
 |
 |
 |
Date :
2011-08-23 10:10:16 |
By :
arm8957 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันก็น่าจะได้ตั้งแต่ผมให้เอา disabled ออกแล้วนะ 
|
 |
 |
 |
 |
Date :
2011-08-23 10:45:26 |
By :
ikikkok |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|