Q - Notice: Undefined variable: response in D:\xampp\htdocs\tools_joomla\tools\convert-area\index.php on line 140

Post a reply


This question is a means of preventing automated form submissions by spambots.
Smilies
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Q - Notice: Undefined variable: response in D:\xampp\htdocs\tools_joomla\tools\convert-area\index.php on line 140

Re: Q - Notice: Undefined variable: response in D:\xampp\htdocs\tools_joomla\tools\convert-area\index.php on line 140

Post by Parichat » 27/09/2018 4:14 pm

ปัญหา
เกิดจากประกาศตัวแปรคนละเงื่อไขกัน

วิธีแก้ไข
ย้ายตัวแปรที่ประกาศไว้มาวางไว้ในเงือนไขที่โปรแกรมทำงาน ดังโค้ด

Code: Select all

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'] . '" />';
   }
}

Q - Notice: Undefined variable: response in D:\xampp\htdocs\tools_joomla\tools\convert-area\index.php on line 140

Post by 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 แต่ในโค้ดประกาศตัวแปรไว้เรียบร้อยแล้วดังโค้ด

Code: Select all

$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'] . '" />';
                            }

แก้ไขอย่างไรค่ะ
ขอบคุณค่ะ

Top