Confirmation Message Code

The code below works fine except the "msg" code. I'm trying to fix it so after the user types in the information in the form, then they click submit, a msg box pops up showing what they are about to submit with an OK. button. Once they click the submit button it gets submitted to the mysql database....is this possible?
<script type="text/javascript">   
 
function checkme() {    
if(!document.forms[0].date_disclo_att.value.match(/^\d{4}-\d{1,2}-\d{1,2}$/)) {   
alert("ATTENTION: Please enter the 'Submitted to Atlas' date in the format yyyy-mm-dd.");   
document.forms[0].date_disclo_att.focus();     
return false; 
}  

if(!document.forms[0].date_sub_crt.value.match(/^\d{4}-\d{1,2}-\d{1,2}$/)) {   
alert("ATTENTION: Please enter the 'Submitted to class' date in the format yyyy-mm-dd.");   
document.forms[0].date_sub_crt.focus();     
return false; 
} 

 msg="You are about to enter the following data into the training database:\n"; 
        msg+="\nPACTS No: " + document.forms[0].pacts.value; 
        msg+="\nFirst Name: " + document.forms[0].fname.value; 
        msg+="\nLast Name: " + document.forms[0].lname; 
        msg+="\nDate Submitted to Class: " + document.forms[0].date_sub_crt; 
        msg+="\nDate Submitted to Atlas: " + document.forms[0].date_disclo_att;  
        msg+="\n\nAre you sure you want to continue?";
		msg+="\n\nIf so, click OK, if not click CANCEL to re-enter your information?";	
         
        if (confirm(msg)) 
                { return true; } 
        return false;

else {return true}  
} 

</script> 

<?php

echo '<form action="clerk_edit.php" method="post">
<fieldset><legend><h2> You are editing a record! After submitting this form, your DQA will be notified of the change via email.</h2></legend>

<b>PACTS No:</b> <br><input type="text" name="pacts" size="15" maxlength="30" value="'.$row[0].'" /><br>
<b>First Name:</b> <br><input type="text" name="fname" size="15" maxlength="30" value="'.$row[1].'" /><br />
<b>Last Name:</b> <br><input type="text" name="lname" size="15" maxlength="30" value="'.$row[2].'" /><br />
<b>Submitted to class: </b><br><input type="text" name="date_sub_crt" size="15" maxlength="30" value="'.$row[3].'" onchange="checkme()"/> <br>
<b>Submitted to atlas: </b><br><input type="text" name="date_disclo_att" size="15" maxlength="30" value="'.$row[4].'" onchange="checkme()"/> <br>
</fieldset>

<div align="left"><input type="submit" name="submit" value="Submit" /></div> 

<input type="hidden" name="submitted" value="TRUE" />
<input type="hidden" name="id" value="' . $id . '" />
</form>';

Open in new window

LVL 15
wantabe2Asked:
Who is Participating?
 
Michel PlungjanIT ExpertCommented:
can we not take it a little further?
<script type="text/javascript">   
 
function checkme(theForm) {    
  if(!theForm.date_disclo_att.value.match(/^\d{4}-\d{1,2}-\d{1,2}$/)) {   
    alert("ATTENTION: Please enter the 'Submitted to Atlas' date in the format yyyy-mm-dd.");   
    theForm.date_disclo_att.focus();     
    return false; 
  }  

  if(!theForm.date_sub_crt.value.match(/^\d{4}-\d{1,2}-\d{1,2}$/)) {   
    alert("ATTENTION: Please enter the 'Submitted to class' date in the format yyyy-mm-dd.");   
    theForm.date_sub_crt.focus();     
    return false; 
  } 

  msg= "You are about to enter the following data into the training database:\n"; 
  msg+="\nPACTS No: " + theForm.pacts.value; 
  msg+="\nFirst Name: " + theForm.fname.value; 
  msg+="\nLast Name: " + theForm.lname; 
  msg+="\nDate Submitted to Class: " + theForm.date_sub_crt; 
  msg+="\nDate Submitted to Atlas: " + theForm.date_disclo_att;  
  msg+="\n\nAre you sure you want to continue?";
  msg+="\n\nIf so, click OK, if not click CANCEL to re-enter your information?";	
  return confirm(msg) 
} 

</script> 

<form action="clerk_edit.php" method="post" onSubmit="return checkme(this)">
<fieldset><legend><h2> You are editing a record! After submitting this form, your DQA will be notified of the change via email.</h2></legend>

<b>PACTS No:</b> <br /><input type="text" name="pacts" size="15" maxlength="30" value="<?php echo $row[0]; ?>" /><br />
<b>First Name:</b> <br /><input type="text" name="fname" size="15" maxlength="30" value="<?php echo $row[1]; ?>" /><br />
<b>Last Name:</b> <br /><input type="text" name="lname" size="15" maxlength="30" value="<?php echo $row[2]; ?>" /><br />
<b>Submitted to class: </b><br /><input type="text" name="date_sub_crt" size="15" maxlength="30" value="<?php echo $row[3]; ?>"/> <br />
<b>Submitted to atlas: </b><br /><input type="text" name="date_disclo_att" size="15" maxlength="30" value="<?php echo $row[4]; ?>" /> <br />
</fieldset>

<div align="left"><input type="submit" value="Submit" /></div> 
<input type="hidden" name="submitted" value="TRUE" />
<input type="hidden" name="id" value="<?php echo id; ?>" />
</form>

Open in new window

0
 
hexer4uCommented:
replace
<form action="clerk_edit.php" method="post">
with
<form action="clerk_edit.php" method="post" onsubmit="return checkme();">

and make sure you always return a true or false;
0
 
wantabe2Author Commented:
hexer4u,
I get

 Parse error: syntax error, unexpected '<' in C:\wamp\www\flow\query\clerk_edit.php on line 156

which is line:

<form action="clerk_edit.php" method="post" onsubmit="return checkme();">
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Michel PlungjanIT ExpertCommented:
Please try mine. Simplified the html and the confirm
0
 
Ray PaseurCommented:
It's important to be able to correct PHP parse errors.  You might find this book helpful to get a foundation in PHP.  If I have recommended it to you before (I recommend it frequently when I see someone struggling with the basics) that is because it is a really good learning resource.  Very readable, great explanations, strong examples, a downloadable code library -- all in one place.
http://www.sitepoint.com/books/phpmysql4/
0
 
hexer4uCommented:
Paste the entire line if you can't get it to work.
I really suggest using an editor that understands php, html and js. I recommend Netbeans with PHP.
It will highlight errors just like MS Word.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.