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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook 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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.