หัดเขียนเว็บครับ สงสัยการใช้ POST form

เริ่มโดย Mahome, 20 กรกฎาคม 2014, 02:40:20

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

Mahome

ผมทำอะไรผิดไปครับ ทำไมมันไม่ยอมส่งค่า ไป test2 ครับ

นี้ใน file test.HTML
อ้างถึง<!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=utf-8" />
<title>Untitled Document</title>
</head>

<body>
[div class=\'codetop\']CODE[div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']
<form action="test2.php" method="post" name="RegisFrm" id="RegisFrm">
  <table width="100%" border="0" cellspacing="2" cellpadding="0">
    <tr>
      <td width="13%"><div align="right">Name :</div></td>
      <td width="87%"><input name="name" type="text" id="name"></td>
    </tr>
    <tr>
      <td><div align="right">Surname :</div></td>
      <td><input name="surname" type="text" id="surname"></td>
    </tr>
    <tr>
      <td><div align="right">Age :</div></td>
      <td><input name="age" type="text" id="age" size="5"></td>
    </tr>
    <tr>
      <td><div align="right">Sex :</div></td>
      <td><input name="sex" type="radio" value="male" checked> Male
        <input type="radio" name="sex" value="female"> Female </td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type="submit" name="Submit" value="Register"></td>
    </tr>
  </table>
</form>
</body>
</html>


นี้ใน test2.php
อ้างถึง<!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=utf-8" />
<title>Untitled Document</title>
</head>

<body>
[div class=\'codetop\']CODE[div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']
<?php
$name = $_POST['name'];
$surname = $_POST['surname'];
$age = $_POST['age'];
$sex = $_POST['sex'];
?>
</body>
</html>
[direct=http://www.matell.in.th]MATELL[/direct]

zazane

วิธีหาเงินที่ง่ายๆ วันละ 350 ผ่านเว็บครอบลิงค์[direct=http://onemore10now.blogspot.com]คลิกเลยค่ะ[/direct]
popup เจ้านี้ สมัครง่าย ทำเงินง่าย[direct=https://www.popads.net/users/refer/519628]ทางนี้[/direct]
โฮสติ้งคุณภาพสูง ราคาถูก มาตรฐาน ISO เจ้าเดียวในไทย
[direct=https://my.thaidatahosting.com/aff.php?aff=227][/direct]
[direct=http://bit.ly/2yY8lhN]pauy[/direct]

zapanlek

ก็ไม่มีอะไรผิดนะครับ งง ไม่ได้ echo ค่าออกมาหรือเปล่า  :wanwan012:
ผมชอบเวปนี้
www.aixfs.com

Mahome

dynamically-related files cannot not be discovered because there is no site definition for this document.

มัมมี alert แบบ นี้หมายความว่าไง ครับ
[direct=http://www.matell.in.th]MATELL[/direct]

iC1assicTh

ตรง test2.php ลอง


<?php

$name 
$_POST['name'];
$surname $_POST['surname'];
$age $_POST['age'];
$sex $_POST['sex'];

echo 
$name "<br/>";
echo 
$surname "<br/>";
echo 
$age "<br/>";
echo 
$sex;

?>



[direct=http://www.fittechrayong.com/]ฟิตเนส ระยอง[/direct] : [direct=http://elec.fc2ry.com/]อะไหล่อิเล็กทรอนิกส์[/direct] : [direct=http://www.btn-electronics.com/]อะไหล่ตู้เชื่อม[/direct] : [direct=http://mpfix.fc2ry.com/]ซ่อมเครื่องใช้ไฟฟ้า ระยอง[/direct]

Mahome

อ้างถึงจาก: iC1assicTh ใน 20 กรกฎาคม 2014, 03:20:35
ตรง test2.php ลอง


<?php

$name 
$_POST['name'];
$surname $_POST['surname'];
$age $_POST['age'];
$sex $_POST['sex'];

echo 
$name "<br/>";
echo 
$surname "<br/>";
echo 
$age "<br/>";
echo 
$sex;

?>



ลองทำตามแล้วครับ ผลลัพท์ ออกมาแบบนี้ครับ
อ้างถึง[div class=\'codetop\']CODE[div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\'] "; echo $surname."
"; echo $age."
"; echo $sex; ?>
[direct=http://www.matell.in.th]MATELL[/direct]

zero1150kfc

div มันใช้แบบนี้หรือเปล่าครับ

หรือผมตกยุค

<div cass...></div>
วีพีเอสถูก บริการเช่าเครื่อง Server (เสมือน)ราคาถูกจาก VPSTOOK เริ่มต้นเพียง 350 บาทเท่านั้น!!
ได้รับการบริการที่เหนือกว่าในราคาที่ถูกกว่าท้องตลาดทั่วไป
Free กันยิง Firewall (DNS Amp, NTP Amp, MSSQL Amp, SSDP)
สามารถอ่านรายละเอียดได้ที่ [direct=https://www.vpstook.com]VPSTOOK.COM[/direct]

jirawats

ถ้าทำในเครื่อง pc ไม่ทราบว่า โปรแกรม web server ทำงานปกติรึเปล่าครับ

kppser

test2.php
โค้ด (php) เลือก
<?php
$name 
$_POST['name'];
$surname $_POST['surname'];
$age $_POST['age'];
$sex $_POST['sex'];
echo  
$name.'<br>';
echo 
$surname.'<br>';
echo 
$age.'<br>';
echo  
$sex.'<br>';
?>

krusnai

ผมลอง run code ที่คุณเจ้าของกระทู้ เขียน echo แล้ว ค่าก็ออกมาปกตินะครับ
เลยคิดว่าเป้นที่ สาเหตุอืน ลงอไป search เห็นว่าอาจเกินจาก dreamCS5 + settine site ครับ

http://www.thaicreate.com/php/forum/082582.html 

ลองดูครับ   :wanwan012: :wanwan012:


sputtaro

ผมยังไม่ได้ลองทดสอบโค้ดของ จขกท. นะครับ
แต่เท่าที่ดู ในไฟล์ test2.php

ท่านไม่ได้สั่งให้มันแสดงค่าโดยการเพิ่มคำสั่ง echo ครับ ตามที่มีผู้แนะนำแล้ว
สคริปท์นี้ทำงานแล้วโดยการเก็บค่าตัวแปรไว้ในหน่วยความจำแล้ว แต่ไม่แสดงผลออกมาให้เห็น

ส่วนกรณ๊คำสั่ง [div] นั้น
ผมเข้าใจว่าอาจใช้โปรแกรมอื่นช่วยออกแบบ แต่ถ้าไม่ใช้โปรแกรมอื่นช่วยแปรคำสั่งอีกที
มันผิดหลักการเขียนครับ
มันต้องเขียน <div class="...."> ...... </div>
มิฉะนั้นมันจะแสดงผล หรือไม่แสดงผล อย่างที่เราต้องการ

Mahome

อ้างถึงจาก: jirawats ใน 20 กรกฎาคม 2014, 09:41:18
ถ้าทำในเครื่อง pc ไม่ทราบว่า โปรแกรม web server ทำงานปกติรึเปล่าครับ
มือใหม่จริงๆ ครับ อะไรคือ web server ครับ
[direct=http://www.matell.in.th]MATELL[/direct]

sbaydee

ติดตั้งโปรแกรม apache หรือ xampp ไว้รัน php รึยังครับ

Mahome

อ้างถึงจาก: sbaydee ใน 20 กรกฎาคม 2014, 13:03:26
ติดตั้งโปรแกรม apache หรือ xampp ไว้รัน php รึยังครับ

ยังเลยครับ คืออะไรครับ  :P
[direct=http://www.matell.in.th]MATELL[/direct]

sbaydee

อ้างถึงจาก: Mahome ใน 20 กรกฎาคม 2014, 13:06:00
อ้างถึงจาก: sbaydee ใน 20 กรกฎาคม 2014, 13:03:26
ติดตั้งโปรแกรม apache หรือ xampp ไว้รัน php รึยังครับ

ยังเลยครับ คืออะไรครับ  :P
มันคือโปรแกรมที่ทำให้เครื่องเรา(pc,mac) ทำงานเป็น web server ซึ่ง PHP จำเป็นต้องรันบน webserver เท่านั้นครับลองไปศึกษาที่นี่ดูครับ
การติดตั้ง XAMPP (PHP+MYSql+PHPMyAdmin)

Mahome

อ้างถึงจาก: sbaydee ใน 20 กรกฎาคม 2014, 13:14:11
อ้างถึงจาก: Mahome ใน 20 กรกฎาคม 2014, 13:06:00
อ้างถึงจาก: sbaydee ใน 20 กรกฎาคม 2014, 13:03:26
ติดตั้งโปรแกรม apache หรือ xampp ไว้รัน php รึยังครับ

ยังเลยครับ คืออะไรครับ  :P
มันคือโปรแกรมที่ทำให้เครื่องเรา(pc,mac) ทำงานเป็น web server ซึ่ง PHP จำเป็นต้องรันบน webserver เท่านั้นครับลองไปศึกษาที่นี่ดูครับ
การติดตั้ง XAMPP (PHP+MYSql+PHPMyAdmin)


ลงเรียบร้อยแล้วทำยังไงต่อครับ
[direct=http://www.matell.in.th]MATELL[/direct]

Mahome

ต้องเอา file ไปวางไว้ที่ไหนครับ ถึงจะ run ได้ ครับ
[direct=http://www.matell.in.th]MATELL[/direct]

Mahome

ผมเอา file test1.html กับ test2.php ไปวางใน xampp/htdocs แล้วครับ พอทดสอบกดปุ่ม register จาก test1.html มันก็กลายเป็น download file test2.php แทนครับ
[direct=http://www.matell.in.th]MATELL[/direct]

siamjung

ใน addres bar คุณเรียก url ยังไงครับ http://localhost/... หรือป่าว หรือเรียกตาม path ? ใน computer ?
งดรับงาน custom coding เตรียมพบบริการใหม่เร็วๆนี้

รับทำ PHP หรือปรับระบบระดับ bigbig เน้น cache คนเข้าแบบกระฉูดๆ <- สมัยก่อน

KendoUI,Ajax,Json,Custom Framework,JqueryUI,Adodb,Memcache,Smarty <- สมัยก่อน

[direct=https://www.youtube.com/watch?v=2LxLC93Q1rA]Indicator สัญญาณเทรดคมๆ[/direct]

[direct=https://play.google.com/store/apps/details?id=com.itwetrade.basictrade]App เรียนเทรดพื้นฐาน[/direct]

Mahome

อ้างถึงจาก: siamjung ใน 20 กรกฎาคม 2014, 17:52:40
ใน addres bar คุณเรียก url ยังไงครับ http://localhost/... หรือป่าว หรือเรียกตาม path ? ใน computer ?

:o  ได้แล้วครับ ขอบคุณมาก ครับ
[direct=http://www.matell.in.th]MATELL[/direct]