PHP with Javascript: Email confirmation script not working

Posted by Josh K on Stack Overflow See other posts from Stack Overflow or by Josh K
Published on 2010-05-13T20:18:27Z Indexed on 2010/05/13 20:34 UTC
Read the original article Hit count: 253

Filed under:
|

Hey Heres what i got:

  echo "<script type=\"text/javascript\">
    function finishForm() {
     var answer = confirm('Are you sure these are the teams you want to enter with?');
     if (answer) {
      if(document.getElementByID(emailconfirm).value == ".$_SESSION[Email].") {
       form.action=\"esubmit.php\";
       form.submit();
      } else {
       alert('E-mail address do not match');
       return false;
      }
     } 
    }
    function restartForm() {
     var answer = confirm('Are you sure you want to start over?');
     if (answer) {
      form.action=\"e1.php\";
      form.submit();
     }
    }
     </script>";  

I have a regular button calling this function. emailconfirm is a text input.
I want to confirm that they have chosen the right teams, then check if the email in the session and the email confirmation text match. If they do match Then i want to submit the form.
If they dont match, I want to alert the user they dont match, and just return to page so user can check emails and then resubmit.
This script is in my header.

EDIT: Haha sorry i submitted one before and it didnt go through, forgot to add my problem!!

When you click the button it comes up with the confirmation, clicking either yes or no doesnt do anything. The alert doesnt pop up if they dont match and if they do match it doesnt submit. Also it might be good to note I had it without the email confirmation if statement and it worked fine (going to the submit page)

© Stack Overflow or respective owner

Related posts about php

Related posts about JavaScript