0

I have a form forgot password that confirms if the user exists and send a email with a link for password reset, it works fine but i do like that message "email was been sent..." should appear in a popup instead on the same page.

I tried this but does not works:

response.php

var useremail = document.getElementById("email").value();
$.get( "validation.php?email="  function( response ) {
    // console.log( response ); // server response
    response = response.trim();
    if(response == 1){
        alert("Email sent....");
    } else{
        alert(response);
        return false;
    }
});

}`

Form:

<form class="register" id="email" action="forgot.php" method="post" onSubmit="checkAll();">

mysql

if ($result=="") { $result = "Email has been sent"; }
  echo "<div>$result</div>";
}
?>```
k4li
  • 39
  • 4
  • So basically you want the message to be shown in a popup! If you want to do so then just inlcude the code for the pop-up inside the if statement. You may check this question for popup... https://stackoverflow.com/questions/1328723/how-to-generate-a-simple-popup-using-jquery – Abdul Muheet Jun 03 '22 at 11:06
  • thanks for the reply but inside the if statement always break the whole code and the page does not loads. – k4li Jun 03 '22 at 11:41
  • In that case you made some error in including it, you need to debug it – ADyson Jun 03 '22 at 15:41

1 Answers1

0

I have sorted all and now it works i let here the solution in a hope that can helps someone else:

function alert(){
  echo "<script type='text/javascript'>";
  echo "alert('Email has been sent - Please click on the link in the email to confirm.');";
  echo "</script>";
  }
  
  


 
    if ($result=="") { $result = alert(); }
    }

?>
k4li
  • 39
  • 4