1

when i try to Sign up echo json commands for existing email i get this error

Use of undefined constant Email_Error - assumed 'Email_Error' (this will throw an Error in a future version of PHP) in C:\xamppnew\htdocs\android\signup.php on line 16 {"SIGNUP":"Email_Error"}

and when there is no error i get this error

Notice: Undefined variable: arr in C:\xamppnew\htdocs\android\signup.php on line 23 null

php code

<?php
 include "conn.php";

 $Fname = $_POST['Fname'];
 $Lname = $_POST['Lname'];
 $Email = $_POST['Email'];
 $Password = $_POST['Password'];

 $sql_verify = "SELECT * FROM users WHERE Email = :EMAIL";
 $stmt = $PDO->prepare($sql_verify);
 $stmt->bindParam(':EMAIL', $Email);
 $stmt->execute();

 if ($stmt->rowCount() > 0) {

  $arr = array( 'SIGNUP' => Email_Error);


 }else{
    echo "Signup compelete";
 }

 echo json_encode($arr);


?>

note im following php manual for json

Phil
  • 157,677
  • 23
  • 242
  • 245
  • 1
    `$arr = array( 'SIGNUP' => Email_Error);` quotes, or lack of them `$arr = array( 'SIGNUP' => 'Email_Error')` – ArtisticPhoenix Mar 20 '19 at 01:05
  • 1
    Your `$arr` variable is only defined in one logic branch. It is potentially undefined if `$stmt->rowCount()` returns a value equal to or less-than zero – Phil Mar 20 '19 at 01:06
  • 2
    better to move the `echo json_encode` into there, as the other output `echo "Signup compelete";` will invalidate the JSON. Assuming it existed there. That whole bottom part is kind of a mess, I suppose. but you can fix that later... lol – ArtisticPhoenix Mar 20 '19 at 01:07

0 Answers0