|
|
|
ผมทดสอบเขียนโค้ดครับ ไม่ทราบว่าโอเครึเปล่าครับ ทดลองเขียน php ครั้งแรกครับผม |
|
|
|
|
|
|
|
Code (PHP)
<!DOCTYPE html>
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<title>Lab6</title>
</head>
<body>
<div><form method="post" action="index2.php">
<table border="0" width="500" style="background-color:#E6E6FA">
<tbody>
<tr>
<th>ชื่อผู้ใช้งาน :<font color="red">*</font></th>
<td><input type="text" name="uname" class="username" placeholder="Username"></td>
</tr>
<tr>
<th>รหัสผ่าน :<font color="red">*</font></th>
<td><input type="password" name="pass" maxlength=12 class="pass" placeholder="Password"></td>
</tr>
<tr>
<th>ยืนยันรหัสผ่านอีกครั้ง :<font color="red">*</font></th>
<td><input type="password" name="re-pass" maxlength=12 class="repass" placeholder="Re-Password"></td>
</tr>
<tr>
<th>ชื่อ :<font color="red">*</font></th>
<td><input type="text" name="name" class="name"></td>
</tr>
<tr>
<th>นามสกุล <font color="red">*</font></th>
<td><input type="text" name="lastname" class="lastname"></td>
</tr>
<tr>
<th>เพศ:<font color="red">*</font></th>
<td><input type="radio" name="gender" value="ชาย"> ชาย
<input type="radio" name="gender" value="หญิง"> หญิง</td>
</tr>
<tr>
<th>วันเดือนปีเกิด :<font color="red">*</font></th>
<td>
<select name="birthday" class="birthday">
<option selected>-- วัน --</option>
<?php
for($i=1;$i<=31;$i++){
echo "<option>$i</option>";
}
?>
</select>
<select class="month" name="month">
<option selected>-- เดือน --</option>
<?php
$val=array("มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤศจิกายน","ธันวาคม");
foreach ($val as $month) {
echo "<option>$month</option>";
}
?>
</select>
<select class="year" name="year">
<option selected>-- ปี --</option>
<?php
for($j=2500;$j<=2600;$j++) {
echo "<option>$j</option>";
}
?>
</select>
</td>
</tr>
<tr>
<th>Email :<font color="red">*</font></th>
<td><input type="text" name="mail" class="mail"></td>
</tr>
<tr>
<th>เบอร์โทรศัพท์ :</th>
<td><input type="text" name="tel" class="tel"></td>
</tr>
<tr>
<th>ที่อยู่:<font color="red">*</font></th>
<td><textarea cols="40" rows="5" class="address" name="address"></textarea></td>
</tr>
<tr>
<th>จังหวัด :<font color="red">*</font></th>
<td><select name="province" class="province">
<option value="เชียงใหม่">เชียงใหม่</option>
<option value="กรุงเทพ">กรุงเทพ</option></select>
</td></tr>
<tr>
<td></td><td><input type="checkbox" name="chk" value="go"> ยอมรับข้อตกลงในการลงทะเบียน</td>
</tr>
<tr><td></td><td><input type="submit" name="submit" value=" ยืนยัน ">
</td>
</tr>
</tbody></table>
</form>
</div>
</body>
</html>
Tag : PHP
|
|
|
|
|
|
Date :
2016-11-30 23:08:12 |
By :
theChang |
View :
748 |
Reply :
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
if($_POST["chk"]==NULL){
echo "กรุณายอมรับข้อตกลง ";
exit();
}//end if
if($_POST["pass"] != $_POST["re-pass"]){
echo "รหัสผ่านไม่เหมือนกัน";
exit();
}//end if
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
</head>
<body ="1px">
<H2 align="center"><FONT COLOR="red">ลงทะเบียนสำเร็จ!</FONT></H2>
<center>
<HR>
<TABLE border="0" width="600">
<TR>
<TD>
<?php
function GetName($name, $lastname){
echo "<H3>สวัสดีคุณ : ".$_POST["name"]." ".$_POST["lastname"]." </H3>";
}
GetName(" ", " ");
?>
ข้อมูลการลงทะเบียนของท่านคือ... <BR><BR>
ชื่อผู้ใช้งาน : <?php echo $_POST["uname"];?><br>
<?php $pws= $_POST["pass"];?>
รหัสผ่าน : <?php echo str_repeat("*", strlen($pws));?><br>
Email : <?php echo $_POST["mail"];?><br>
<?php echo "เพศ : ".$_POST['gender'];?><BR>
<?php echo "วันเดือนปีเกิด : ".$_POST['birthday'].$_POST['month'].$_POST['year']; ?><BR>
<?php echo "เบอร์โทรศัพท์ : ".$_POST['tel'];?><BR>
วันที่และเวลาที่ลงทะเบียน :
<?php
echo date("Y-m-d H:i:s");
?>
</TD>
</TR>
</TABLE>
</center>
</body>
</html>
|
|
|
|
|
Date :
2016-11-30 23:09:00 |
By :
geseus |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
add customer
Code (PHP)
<!DOCTYPE html>
<meta http-equiv=Content-Type content="text/html; charset=tis-620">
<html>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<body style="background-color:#e0ffe0" >
<?php
$mount=array("มกราคม","กุมภาพันธ","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤศจิกายน","ธันวาคม");
?>
<form method="post" action="">
<center><fieldset style ="width:40%">
<legend><span style="font-size: 22px; color: #1fc196;">ข้อมูลลูกค้า</span></legend>
<center><table>
<tr>
<td>ชื่อ :</td>
<td><input type="text" name="fname" class="form-group form-control"></td>
</tr>
<tr>
<td>นามสกุล :</td>
<td><input type="text" name="lname" class="form-group form-control"></td>
</tr>
<tr>
<td>เพศ:</td>
<td><input type="radio" name="gender" value="Male"> Male <input type="radio" name="gender" value="Female"> Female </td>
</tr>
<tr>
<td>อายุ :</td>
<td><input type="text" name="age" class="form-group form-control"></td>
</tr>
<tr>
<td>วัน-เดือน-ปี เกิด :</td>
<td><input type="date" name="date" class="form-group form-control"></td>
<tr>
<td>ที่อยู่:</td>
<td><input type="text" name="address" class="form-group form-control"></td>
</tr>
<tr>
<td>จังหวัด:</td>
<td><input type="text" name="province" class="form-group form-control"></td>
</tr>
<tr>
<td>รหัสไปรษณีย์ :</td>
<td><input type="text" name="zipcode" class="form-group form-control"></td>
</tr>
<tr>
<td>โทรศัพท์ :</td>
<td><input type="text" name="telephone" class="form-group form-control"></td>
</tr>
<tr>
<td>รายละเอียดอื่นๆ:</td>
<td><input type="text" name="customer_description" class="form-group form-control"></td>
</tr>
</tr>
</table></center>
</fieldset>
<fieldset style ="width:40%">
<legend><span style="font-size: 22px; color: #1fc196;">Account ของลูกค้า</span></legend>
<center><table>
<tr>
<td>Username :</td>
<td><input type="text" name="user" class="form-group form-control"></td>
</tr>
<tr>
<td>Password :</td>
<td><input type="password" name="pass" class="form-group form-control"></td>
</tr>
<tr>
<td>Confirm Password :</td>
<td><input type="password" name="con" class="form-group form-control"></td>
</tr>
<tr>
<td><input type="submit" value="Submit" class="btn btn-success" name="Submit"></td>
<a href="add_customer.php" class="btn btn-success" style="margin: 20px;">Cancel</a>
</tr></table>
</fieldset>
</form>
<?php
$host="localhost:8081";
$user="root";
$pass="";
$db="mystore";
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("mystore") or die(mysql_error());
error_reporting( error_reporting() & ~E_NOTICE );
mysql_query("SET NAMES 'utf8'");
$fname=$_POST['fname'];
$lname=$_POST['lname'];
$garden=$_POST['gender'];
$age=$_POST['age'];
$date=$_POST['date'];
$address=$_POST['address'];
$province=$_POST['province'];
$zipcode=$_POST['zipcode'];
$telephone=$_POST['telephone'];
$customer_description=$_POST['customer_description'];
$user=$_POST['user'];
$pass1=$_POST['pass'];
$pass2=$_POST['con'];
if (isset($fname) && $_POST['user']!=null && $_POST['Submit']) {
if($pass1==$pass2){
$sql="INSERT INTO customer(Customer_Name,Customer_Lastname,Gender,Age,Birthdate,Address,Province,Zipcode,
Telephone,Customer_Description,username,password)
VALUES('$fname','$lname','$garden','$age','$date','$address','$province','$zipcode',
'$telephone','$customer_description','$user','$pass')";
mysql_query($sql);
header('location: ./Lab7_53543206043-7.php');
}else{
echo "รหัสผ่านไม่ตรงกัน";
}
}
if (isset($_POST['Cancel'])) {
header('location: ./Lab7_53543206043-7.php');
}
if (isset($fname) && $_POST['user']==null && $_POST['Submit']) {
echo "กรุณากรอกข้อมูลของท่านให้ครบครับ";
}
?>
</center>
</body>
</html>
|
|
|
|
|
Date :
2016-11-30 23:09:43 |
By :
geseus |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<!DOCTYPE html>
<html>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<body style="background-color:#e0ffe0" >
<center>
<div class="row">
<span style="font-size: 22px; color: #1fc196;">ลบข้อมูล</span>
</div>
<div class="col-md-4 col-md-offset-4">
<?php
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("mystore") or die(mysql_error());
mysql_select_db("mystore") or die("NOT Select");
mysql_query("SET NAMES UTF8");
if (isset($_GET['uid'])) {
$del=$_GET['uid'];
$row=mysql_query("SELECT * FROM customer WHERE Customer_id='$del'");
while ($b=mysql_fetch_array($row))
{
echo "<form action='del_customer.php' method='POST'>";
echo "<input type = 'hidden' name='uid' value='".$b['Customer_id']."' class='form-control'><br> ";
echo "<input type = 'text' name='fname' value = '".$b['Customer_Name']."' class='form-control' readonly><br>";
echo "<input type = 'text' name='lname' value = '".$b['Customer_Lastname']."' class='form-control' readonly><br>";
echo "<input type = 'text' name='gender' value = '".$b['Gender']."' class='form-control' readonly><br>";
echo "<input type = 'text' name='age' value = '".$b['Age']."' class='form-control' readonly><br>";
echo "<input type = 'text' name='date' value = '".$b['Birthdate']."' class='form-control' readonly><br>";
echo "<input type = 'text' name='address' value = '".$b['Address']."' class='form-control' readonly><br>";
echo "<input type = 'text' name='province' value = '".$b['Province']."' class='form-control' readonly><br>";
echo "<input type = 'text' name='zipcode' value = '".$b['Zipcode']."' class='form-control' readonly><br>";
echo "<input type = 'text' name='telephone' value = '".$b['Telephone']."' class='form-control' readonly><br>";
echo "<input type = 'text' name='customer_description' value = '".$b['Customer_Description']."' class='form-control' readonly><br>";
echo "<input type = 'text' name='user' value = '".$b['username']."' class='form-control' readonly><br>";
echo "<input type = 'text' name='pass' value = '".$b['password']."' class='form-control' readonly><br>";
echo "<input type = 'submit' name='OK' class='btn btn-success' value= 'ลบข้อมูล'>";
echo "<a href='Lab7_53543206043-7.php' class='btn btn-default'>Cancel</a>";
echo "</form>";
}
}
if (isset($_POST['OK'])&&isset($_POST['uid'])){
$a = $_POST['uid'];
$dele = "DELETE FROM customer WHERE Customer_id = '$a'";
mysql_query($dele);
header('location: ./Lab7_53543206043-7.php');
}
if (isset($_POST['Cancel'])){
header('location: ./Lab7_53543206043-7.php');
}
?>
</div>
</center>
</body>
</html>
|
|
|
|
|
Date :
2016-11-30 23:10:16 |
By :
geseus |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<!DOCTYPE html>
<html>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<body style="background-color:#e0ffe0" >
<center>
<div class="row">
<span style="font-size: 22px; color: #1fc196;">แก้ไขข้อมูล</span>
</div>
<div class="col-md-4 col-md-offset-4">
<?php
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("mystore") or die(mysql_error());
mysql_select_db("mystore");
mysql_query("SET NAMES UTF8");
if (isset($_GET['uid'])) {
$del=$_GET['uid'];
$row=mysql_query("SELECT * FROM customer WHERE Customer_id='$del'");
while ($b=mysql_fetch_array($row))
{
echo "<form action='edit_customer.php' method='POST'>";
echo "<input type = 'hidden' name='uid' value='".$b['Customer_id']."' class='form-control'><br> ";
echo "<input type = 'text' name='fname' value = '".$b['Customer_Name']."' class='form-control'><br>";
echo "<input type = 'text' name='lname' value = '".$b['Customer_Lastname']."' class='form-control'><br>";
echo "<input type = 'text' name='gender' value = '".$b['Gender']."' class='form-control'><br>";
echo "<input type = 'text' name='age' value = '".$b['Age']."' class='form-control'><br>";
echo "<input type = 'text' name='date' value = '".$b['Birthdate']."' class='form-control'><br>";
echo "<input type = 'text' name='address' value = '".$b['Address']."' class='form-control'><br>";
echo "<input type = 'text' name='province' value = '".$b['Province']."' class='form-control'><br>";
echo "<input type = 'text' name='zipcode' value = '".$b['Zipcode']."' class='form-control'><br>";
echo "<input type = 'text' name='telephone' value = '".$b['Telephone']."' class='form-control'><br>";
echo "<input type = 'text' name='customer_description' value = '".$b['Customer_Description']."' class='form-control'><br>";
echo "<input type = 'text' name='user' value = '".$b['username']."' class='form-control'><br>";
echo "<input type = 'text' name='pass' value = '".$b['password']."' class='form-control'><br>";
echo "<input type = 'submit' name='OK' class='btn btn-success'>";
echo "<a href='Lab7_53543206043-7.php' class='btn btn-default'>Cancel</a>";
echo "</form>";
}
}
if (isset($_POST['OK'])) {
echo $_POST['uid'];
$id = $_POST['uid'];
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$province = $_POST['province'];
$telephone = $_POST['telephone'];
$up = "UPDATE customer SET Customer_Name ='".$fname."' ,Customer_Lastname='".$lname."',Province='".$province."',Telephone='".$telephone."' WHERE Customer_id='$id'";
mysql_query($up);
header('location: ./Lab7_53543206043-7.php');
}
?>
</div>
</center>
</body>
</html>
|
|
|
|
|
Date :
2016-11-30 23:10:35 |
By :
geseus |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<!DOCTYPE html>
<html>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<body style="background-color:#e0ffe0" >
<center>
<span style="font-size: 22px; color: #1fc196;">ข้อมูลลูกค้า</span>
<fieldset style ="width:40%">
<a href="add_customer.php" class="btn btn-success" style="margin: 20px;">เพิ่มข้อมูลลูกค้า</a>
<div class="table-responsive">
<table class="table table-bordered">
<tr>
<th>ID</th>
<th>ชื่อ</th>
<th>นามสกุล</th>
<th>จังหวัด</th>
<th>โทรศัพท์</th>
<th>แก้ไข</th>
<th>ลบ</th>
</tr>
<?php
$host="localhost";
$user="root";
$pass="";
$db="mystore";
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("mystore") or die(mysql_error());
mysql_query("SET NAMES UTF8");
$head=ucwords("ข้อมูลลูกค้า:");
$data=mysql_query("SELECT * FROM customer");
while ($a=mysql_fetch_array($data) ){
echo "<tr><td>".$a['Customer_id']."</td>
<td>".$a['Customer_Name']."</td>
<td>".$a['Customer_Lastname']."</td>
<td>".$a['Province']."</td>
<td>".$a['Telephone']."</td>
<td><a href='edit_customer.php?uid=".$a['Customer_id']."'>แก้ไข</a></td>
<td><a href='del_customer.php?uid=".$a['Customer_id']."'>ลบ</a></td>
</tr>";
}
?>
</table>
</div>
</center>
</fieldset>
</body>
</html>
|
|
|
|
|
Date :
2016-11-30 23:10:54 |
By :
geseus |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เล่นอะไรหร๋อครับ จะโพสต์ code เอาใส่ tag php สงสัยจะว่าง
|
|
|
|
|
Date :
2016-11-30 23:28:30 |
By :
apisitp |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ถ้าระบบการใช้งาน สามารถใช้งานได้ก็โอเค แต่ควรเปลี่ยนไปใช้ mysqli ครับ
|
|
|
|
|
Date :
2016-12-01 10:06:00 |
By :
dudesaranyu |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|