สำหรับผู้ที่ เริ่มต้น Programming - PHP มีอะไร แนะนำ หรือข้อสงสัยต้องบอร์ด นี้ คนที่มีความรู้ แบ่งปันคนอื่นบ้างนะ ปัญหาการเขียนโปรแกรม แบบ OOP Session Cookies php network
Moderator: mindphp , ผู้ดูแลกระดาน
Parichat
PHP VIP Members
โพสต์: 4859 ลงทะเบียนเมื่อ: 08/01/2018 10:03 am
โพสต์ที่ยังไม่ได้อ่าน
โดย Parichat » 27/09/2018 4:08 pm
Q - Notice: Undefined variable: response in D:\xampp\htdocs\tools_joomla\tools\...\index.php on line 140
Error Undefined variable: response in D:\xampp\htdocs\tools_joomla\tools\...\index.php on line 140
Error ไม่มีตัวแปร response แต่ในโค้ดประกาศตัวแปรไว้เรียบร้อยแล้วดังโค้ด
โค้ด: เลือกทั้งหมด
$response = json_decode(file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=" . $secretkeyrecaptcha . "&response=" . $keyrecaptcha . "&remoteip=" . $_SERVER['REMOTE_ADDR']), true);
//เรียกใช้ตัวแปร $response
if (isset($_POST['name']) && $response['success'] == true) {
echo '<input type = "hidden" name = "id" value = "' . $_POST['name'] . '" />';
}
แก้ไขอย่างไรค่ะ
ขอบคุณค่ะ
Live Simply, Laugh Often, Love Deeply.....
Parichat
PHP VIP Members
โพสต์: 4859 ลงทะเบียนเมื่อ: 08/01/2018 10:03 am
โพสต์ที่ยังไม่ได้อ่าน
โดย Parichat » 27/09/2018 4:14 pm
ปัญหา
เกิดจากประกาศตัวแปรคนละเงื่อไขกัน
วิธีแก้ไข
ย้ายตัวแปรที่ประกาศไว้มาวางไว้ในเงือนไขที่โปรแกรมทำงาน ดังโค้ด
โค้ด: เลือกทั้งหมด
if(.,.,.){
//...
}else {
$response = json_decode(file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=" . $secretkeyrecaptcha . "&response=" . $keyrecaptcha . "&remoteip=" . $_SERVER['REMOTE_ADDR']), true);
if (isset($_POST['name']) && $response['success'] == true) {
echo '<input type = "hidden" name = "id" value = "' . $_POST['name'] . '" />';
}
}
Live Simply, Laugh Often, Love Deeply.....
1 ตอบกลับ
23495 แสดง
โพสต์ล่าสุด โดย thatsawan
12/01/2017 10:16 pm
0 ตอบกลับ
1886 แสดง
โพสต์ล่าสุด โดย mindphp
26/04/2014 4:26 pm
3 ตอบกลับ
2617 แสดง
โพสต์ล่าสุด โดย tsukasaz
24/07/2018 11:12 am
สมาชิกกำลังดูบอร์ดนี้: Google Adsense [Bot] และบุคลทั่วไป 77