First off, if there is a completely better way of doing this? let me know... This way seems kind of "hackish". Here is what I am trying to do: As you see in the below input
, I have a text field that I simple want to appear like an <a>
link. If the user clicks it, I want JavaScript
pop up box to appear with user entering the email. I want them to hit ok, and I send that email value back to the form and the form then submits via a php post.
I do not know how to grab the value from the box and insert it in the form
(if possible) so it can submit to php
.
Here is the code:
<form id="frm1" action="login.php" method = "post">
<input onclick="resetPassword()" type="text" name="email" value="Reset Password" style="cursor: pointer; background:none; text-decoration: underline; border: none;" />
</form>
<script>
function resetPassword() {
var x;
var email=prompt("Enter email to reset password.", "example@email.com");
if (email!=null)
{
document.getElementById("frm1").submit();
}
}
</script>
<?php
if (isset($_POST['email'])) {
$email = $database -> escape_value(trim($_POST['email']));
// reset password
}
?>