PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<script language="javascript">
<!--
function OnButton1()
{
document.Autho.action = "contract.php" // First target
document.Autho.target = "iframe1"; // Open in a iframe
document.Autho.submit(); // Submit the page
document.Autho.action = "mailtest.php"; // Second target
document.Autho.target = "iframe2"; // Open in another iframe
document.Autho.submit(); //Second submit for mailtest.php
return true;
}
-->
</script>
That should post to both the contract.php and the mailtest.php just make sure you make another iframe called iframe2 and use the visibility=hidden to hide it.
EDIT: you should also do some sort of validation for your agree to terms before sending off the email. As it sits now they could easily select do not agree and it would still proccess the form
<script language="javascript">
<!--
function OnButton1()
{
document.Autho.action = "contract.php" // First target
document.Autho.target = "iframe1"; // Open in a iframe
document.Autho.submit(); // Submit the page
document.Autho.action = "mailtest.php"; // Second target
document.Autho.target = "iframe2"; // Open in another iframe
document.Autho.submit(); //Second submit for mailtest.php
return true;
}
-->
</script>
That should post to both the contract.php and the mailtest.php just make sure you make another iframe called iframe2 and use the visibility=hidden to hide it.
EDIT: you should also do some sort of validation for your agree to terms before sending off the email. As it sits now they could easily select do not agree and it would still proccess the form
I added the code as well as the iframe before you posted (sorry for not updating) but still nothing, I only get the 1 contract.php form and nothing from the mailtest.php form.
danwguy wrote:I would think so, you should have a confirmation page in the action part and the 2 pages you need the info sent to in the javascript.
I just did this and it never goes to the confirmation page, and it just stays on the same page and the only information that gets sent is from the 1st javascript command. So I don't get the mailtest.php and that is the 2nd javascript command.
danwguy wrote:try switching the 2 and having mailtest.php as the first submit and see if it goes through or not.
Any time I use the contract.php in the javascript code it sends information only to that php page. Then when I put the contract.php in the form and leave it out of the javascript nothing happens...
Another problem is I can only test the contact form a few times then no packets get sent from any of my forms on the website it seems like. I try stable contact forms and nothing gets sent or comes through.
So even if you put mailtest.php in the first send from the javascript and contract.php as the second, only the contract.php goes through?
repost your mailtest.php so I can take a look at it.
danwguy wrote:So even if you put mailtest.php in the first send from the javascript and contract.php as the second, only the contract.php goes through?
repost your mailtest.php so I can take a look at it.
I see a couple problems in your mailtest.php, unless you are hiding them for security reasons... there is no actual address it is being sent to, the headers should have a mime version and so on, my mail script looks like this...
$cname = $_POST['companyName'];
$addy = $_POST['companyAddress'];
$cphone = $_POST['companyPhone'];
$name = $_POST['contactName'];
$phone = $_POST['contactPhone'];
$email = $_POST['contactEmail'];
$acct = $_POST['knocAccount'];
$to = 'myemailaddresshere';
$subject = 'New Account - ' . $name . ' From ' . $cname;
$message = "<html><head> <title>New Account</title> </head> <body> <p><b>Company Name:</b> " . $cname . "<br /> Company Address: " . $addy . "<br /> Company Phone: " . $cphone . "<br /><br /> <b>Contact Name:</b> " . $name . "<br /> Contact Phone: " . $phone . "<br /> Contact Email: " . $email . "<br /> Knox Account Number: " . $acct . "<br /> </body> </html> ";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
if(!preg_match('/^[0-9]/', $addy)) {
echo "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN'><html><head><link href='../style.css' type='text/css' rel='stylesheet' /></head><body><center><h1 style='font-size: 18px;'>Go <a href='javascript:history.go(-1)'><u style='color: #398bd1;'>Back</u></a> and use a proper address, then re-submit the form</h1></center></body></html>";
echo "<script language='javascript'>alert('Incorrect Address, Please enter a valid numerical address and retry')</script>";
}else{
mail($to, $subject, $message, $headers);
echo "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN'><html><head><meta http-equiv='REFRESH' content='15;url=http://www.knoxservices.com/order/create-account.asp'><link href='../style.css' type='text/css' rel='stylesheet' /></head><body>";
echo "<h2>Your information has been received!</h2><br /><p>Our account reps are reviewing your information now and will be contacting you soon with your new account information. Thanks for creating an account with us!<br />You will be redirected in 15 seconds</p></body></html>";
}
and it works fine, try adding those headers to yours, and put in a valid to address, unless you already have the right to address and you are just hiding it for security reasons.
danwguy wrote:I see a couple problems in your mailtest.php, unless you are hiding them for security reasons... there is no actual address it is being sent to, the headers should have a mime version and so on, my mail script looks like this...
$cname = $_POST['companyName'];
$addy = $_POST['companyAddress'];
$cphone = $_POST['companyPhone'];
$name = $_POST['contactName'];
$phone = $_POST['contactPhone'];
$email = $_POST['contactEmail'];
$acct = $_POST['knocAccount'];
$to = 'myemailaddresshere';
$subject = 'New Account - ' . $name . ' From ' . $cname;
$message = "<html><head> <title>New Account</title> </head> <body> <p><b>Company Name:</b> " . $cname . "<br /> Company Address: " . $addy . "<br /> Company Phone: " . $cphone . "<br /><br /> <b>Contact Name:</b> " . $name . "<br /> Contact Phone: " . $phone . "<br /> Contact Email: " . $email . "<br /> Knox Account Number: " . $acct . "<br /> </body> </html> ";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
if(!preg_match('/^[0-9]/', $addy)) {
echo "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN'><html><head><link href='../style.css' type='text/css' rel='stylesheet' /></head><body><center><h1 style='font-size: 18px;'>Go <a href='javascript:history.go(-1)'><u style='color: #398bd1;'>Back</u></a> and use a proper address, then re-submit the form</h1></center></body></html>";
echo "<script language='javascript'>alert('Incorrect Address, Please enter a valid numerical address and retry')</script>";
}else{
mail($to, $subject, $message, $headers);
echo "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN'><html><head><meta http-equiv='REFRESH' content='15;url=http://www.knoxservices.com/order/create-account.asp'><link href='../style.css' type='text/css' rel='stylesheet' /></head><body>";
echo "<h2>Your information has been received!</h2><br /><p>Our account reps are reviewing your information now and will be contacting you soon with your new account information. Thanks for creating an account with us!<br />You will be redirected in 15 seconds</p></body></html>";
}
and it works fine, try adding those headers to yours, and put in a valid to address, unless you already have the right to address and you are just hiding it for security reasons.
I'm going to add the headers and are you referring to my recipients field when you mean the actual address it is being sent to?
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Apache/1.3.33 Server at commercialrecoveryauthority.com Port 80