Page 2 of 2
Re: PHP contact form, auto-populate and attachment help plea
Posted: Mon Feb 28, 2011 1:26 pm
by Loougle
Ok I didn't have all the right java labels set up, problem is
Code: Select all
<input type="submit" value="Send" name="button1" onclick="return OnButton1 ();"><input type="reset" value="Clear">
</div>
I believe because of the onclick command it does not go to the mailtest.php page anymore.
I did get the contract.php form to submit though.
So I'm 1 step closer, is there another onclick command I can use to send it to mailtest.php?
Re: PHP contact form, auto-populate and attachment help plea
Posted: Mon Feb 28, 2011 2:01 pm
by danwguy
In the javascript function use the whole thing to output to multiple forms, i.e
Code: Select all
<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
Re: PHP contact form, auto-populate and attachment help plea
Posted: Mon Feb 28, 2011 2:14 pm
by Loougle
danwguy wrote:In the javascript function use the whole thing to output to multiple forms, i.e
Code: Select all
<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.
But because I have
Code: Select all
<p style: align="center"><form name="Autho" action="mailtest.php" method="POST">
Could that be why I'm not getting it? should I be having the action go to a different page or something else?
Re: PHP contact form, auto-populate and attachment help plea
Posted: Mon Feb 28, 2011 2:24 pm
by danwguy
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.
Re: PHP contact form, auto-populate and attachment help plea
Posted: Mon Feb 28, 2011 2:43 pm
by Loougle
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.
Re: PHP contact form, auto-populate and attachment help plea
Posted: Mon Feb 28, 2011 3:58 pm
by danwguy
try switching the 2 and having mailtest.php as the first submit and see if it goes through or not.
Re: PHP contact form, auto-populate and attachment help plea
Posted: Tue Mar 01, 2011 1:21 pm
by Loougle
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.
Re: PHP contact form, auto-populate and attachment help plea
Posted: Wed Mar 02, 2011 2:01 pm
by danwguy
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.
Re: PHP contact form, auto-populate and attachment help plea
Posted: Wed Mar 02, 2011 4:54 pm
by Loougle
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.
Code: Select all
<?php
$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$name = $_POST['name'];
$address = $_POST['address'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$d = $_POST['d'];
$da = $_POST[d'a'];
$value = $_POST['chk'];
$pname = $_POST['pname'];
$title = $_POST['title'];
$agree = $_POST['agree'];
$employee = $_POST['employee'];
$formcontent=" From: $name \n Address: $address \n Email: $email \n Phone: $phone \n D: $d \n Address: $da \n 'Client' has read Assignment and Contract Agreement: $value \n Print Name: $pname \n Title: $title \n I hear by agree that the information I have provided is true, accurate and the information I am submitting is not fraudulent. Please click the agree button that you adhere to the terms: $agree \n \n Employee ID: $employee \n IP: $ip";
$recipient = "company emails";
$subject = "Online Authorization Form ";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!" . " -" . "<a href='index.php' style='text-decoration:none;color:#ffcb00;'> Return Home</a>";
$ip = $_POST['visitoraddress']
?>
Changed a few field names since some things are sensitive. Like the recipient emails are just company emails from our domain name.
Re: PHP contact form, auto-populate and attachment help plea
Posted: Wed Mar 02, 2011 7:32 pm
by danwguy
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...
Code: Select all
$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.
Re: PHP contact form, auto-populate and attachment help plea
Posted: Thu Mar 03, 2011 10:56 am
by Loougle
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...
Code: Select all
$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?
Also is
better to use than my
Code: Select all
$recipient = 'myemailaddresshere';
code?
Re: PHP contact form, auto-populate and attachment help plea
Posted: Thu Mar 03, 2011 5:19 pm
by Loougle
I tried to place the header codes into my contact form and it came back a syntax error.
Re: PHP contact form, auto-populate and attachment help plea
Posted: Fri Mar 04, 2011 11:16 am
by danwguy
Post up the new code with header tags, and the error is generated
Re: PHP contact form, auto-populate and attachment help plea
Posted: Wed Mar 09, 2011 1:03 pm
by Loougle
danwguy wrote:Post up the new code with header tags, and the error is generated
I had gotten a syntax error, changed some of the code, and just got an internal error.
Code: Select all
<?php include("password_protect.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> Client Form </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="cra.css" media="all">
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-20830762-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
-->
</script>
<script language="javascript">
<!--
function OnButton1()
{
document.Autho.action = "contract2.php" // First target
document.Autho.target = "iframe1"; // Open in a iframe
document.Autho.submit(); // Submit the page
return true;
}
-->
</script>
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
-->
</style>
</head>
<body vlink="#ffcb00">
<table id="Table_01" width="658" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" style="background-image:url(images/cra_web_logo.gif); background-repeat:no-repeat; width:657px; height:81px;">
<p style="margin-left:20px;margin:0px;background-image:url(cra_logo.gif); background-repeat:no-repeat; float:left;">
<a href="index.php"> <img src="logo.gif" style="margin-left:10px; float:left;border:0px;"></a></p>
<div class="login">
<?php include("login.php"); ?>
</div>
</td>
</tr>
</table>
<table id="Table_02" width="658" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3" valign="top">
<img src="images/main_banner.gif" width="657" height="214" alt=""></td>
</tr>
</table>
<table id="Table_03" width="658">
<tr>
<td style=" background-image:url(index_template_1_03.gif); background-repeat:no-repeat; width:648px; height:33px;">
<?php include("top_nav.php"); ?>
</td>
</tr>
<td colspan="2">
<img src="images/aboutus_template_1_04.gif" width="657" height="21" alt=""></td>
<table width="685" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="441"></td>
</td>
<tr>
<img src="images/client_template_1.gif"><td height="325"> <p style="font-family:Arial, Helvetica, sans-serif; color:#ffffff; font-size:12px; margin-top:40px; margin-left:10px;margin-right:10px; line-height:14px;"><font color="#ffcb00">Online authorization form. Fill this out form and after it is fully and completely filled out please hit the send button at the bottom. If you have not filled out an account placement form, please visit <a href="acct_submission_form.php" style="color:#ffcb00" vlink="#ffcb00">Account Submission Form Page</a> </p>
<br />
<br />
<br />
<br />
<p style: align="center"><form name="Autho" form action="mailtest2.php" method="POST">
<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>
<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />
<div align="center">
<p class="style1">Name</p>
<input type="text" name="name">
<p class="style1">Address</p>
<input type="text" name="address">
<p class="style1">Email</p>
<input type="text" name="email">
<p class="style1">Phone</p>
<input type="text" name="phone">
<p class="style1">D</p>
<input type="text" name="d">
<p class="style1">D Address</p>
<input type="text" name="da">
<br />
<br />
<a href="authoforms.php" target="_blank" style="color:#ffcb00" vlink="#ffcb00">Click here to view Assignment Agreement and Contract Agreement</a>
<p class="style1"><input type='checkbox' name='chk' value='I Have read and Agree to the terms.'> I have read and agree to the Assignment and Contract Agreement <br></p>
<p class="style1">Print Name</p>
<input type="text" name="pname">
<p class="style1">Title</p>
<input type="text" name="title">
<p class="style1">I hear by agree that the information I have provided is true, accurate and the information I am submitting is <br />
not fraudulent. Please click the agree button that you adhere to the terms:</p>
<select name="agree" size="1">
<option value="Agree">Agree</option>
<option value="Disagree">Disagree</option>
</select>
<br />
<br />
<p class="style1">Employee ID:</p>
<input type="text" name="employee">
<br />
<input type="submit" value="Send" name="Button1" ><input type="reset" value="Clear">
</div>
</form>
</p>
<div style="visibility:hidden">
<IFRAME NAME="iframe1" WIDTH="40" HEIGHT="40"></IFRAME>
</div>
</table>
<td width="225" rowspan="2" valign="top" style="background-image:url(images/index_template_1_09.gif); background-repeat:no-repeat;">
<td>
<img src="images/footer.gif" width="657" height="100" alt=""></td>
</body>
</html>
mailtest2.php
Code: Select all
<?php
$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$name = $_POST['name'];
$address = $_POST['address'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$debtor = $_POST['d'];
$debtora = $_POST['a'];
$value = $_POST['chk'];
$pname = $_POST['pname'];
$title = $_POST['title'];
$agree = $_POST['agree'];
$employee = $_POST['employee'];
$formcontent=" From: $name \n Address: $address \n Email: $email \n Phone: $phone \n Debtor: $debtor \n Debtor Address: $debtora \n 'Client' has read Assignment and Contract Agreement: $value \n Print Name: $pname \n Title: $title \n I hear by agree that the information I have provided is true, accurate and the information I am submitting is not fraudulent. Please click the agree button that you adhere to Commercial Recovery Authority Inc.'s terms: $agree \n \n Employee ID: $employee \n IP: $ip";
$recipient = "accounts@domain.com";
$subject = "Online Authorization Form 33.3% Confirmation";
$mailheader = "From: $email \r\n";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($recipient, $subject, $formcontent, $mailheader, $headers) or die("Error!");
echo "Thank You!" . " -" . "<a href='index.php' style='text-decoration:none;color:#ffcb00;'> Return Home</a>";
$ip = $_POST['visitoraddress']
?>
contract2.php
Code: Select all
<?php
$from = "Support <support@domain.com>";
$to = "Accounts <accounts@domain.com>";
$subject = "Online Authorization Form 33.3% Confirmation";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$pname = $_POST['pname'];
$title = $_POST['title'];
$formcontent=" Agreement
By: ___________________________________________ By: _______________________________________________
Print Name: $pname Print Name: ________________________________________
Title: $title Title: ______________________________________________";
$recipient = "accounts@domain.com";
$subject = "Online Authorization Form 33.3%";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($recipient, $subject, $formcontent, $headers ) or die("Error!");
$ip = $_POST['visitoraddress']
?>
Error message
Internal Server Error
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
Re: PHP contact form, auto-populate and attachment help plea
Posted: Wed Mar 09, 2011 1:31 pm
by Loougle
Also even with the error message 1 message got sent, the mailtest2.php got sent, so I'm back to not having the javascript being sent.