Jump to content

Automated Email (Extra Coding)


Paige1710

Recommended Posts

I've never really coded php/javascript before.  But I wanted to send an automated email with all the information I needed to confirm with my clients straight away.  I found a site and began trying a few things, but now I am stuck.  I have a form which they need to fill out...

 

<form method="post" action="mailer.php">

Name (Required): <input type="text" name="name"/><br><br>

Email (Required): <input type="text" name="email"/><br><br>

Website URL: <input type="text" name="website"/><br><br>

Purchase Domain (Required): <input type="radio" name="domain" value="yes">Yes

<input type="radio" name="domain" value="no">No<br><br>

Domain Name (Required): <input type="text" name="domainname"/><br><br>

Package (Required): <input type="text" name="package"/><br><br>

Paypal Email (Required): <input type="text" name="paypal"/><br><br>

Ref. Number:<input type="text" name="refnum"/><br><br>

Message:<br><textarea name="message" cols="30" rows="7"></textarea><br><br>

<input type="submit" value="Send"/>

 

and then the sperate mailer.php file...

 

<?php

if(isset($_POST['submit'])) {

$ip=$_SERVER['REMOTE_ADDR'];

$email_field = $_POST['email'];

$subjecte = "Order Confirmation";

 

$name = $_post['name'];

 

$body = "Hello $name, \n

<p>

<b>PLEASE SAVE THIS AS A RECORD - READ THIS EMAIL IN FULL<b>

<p>

Thank you for choosing Ultimatum Hosting, we appreciate all the business we get and will visit your site often, not

just as a host, but as someone you can rely on.  If you are recieving this message it means we have recieved your order.

You have chosen the $package Package.  If any of this information is incorrect, please reply with the correct details

of the Package you require.

<p>

While the details of your order are being processed we must confirm that you have read the Terms on our site.  These

are very important, as breaking any of them may result in Account Suspension and eventually Termination.

<p>

You should recieve an email from paypal requesting the amount needed from email address (my other email

address).  As soon as the amount is paid in full, you will recieve an email from me with all your account details.

<p>

var good;

function checkdomain(field) {

var goodpackage = field.value.match('yes')};

if (goodpackage) {good = true;document.write("The Package you have chosen comes with a free Domain name/You have requested a Domain name with your package.  While

everything is being processed can you please send a reply with your requested Domain name so that we can order it

ready for you")}

else {good = false;document.write("-")}

}

";

 

echo "An email has been sent to $email_field.";

mail($email, $subjecte, $body);

} else {

 

echo "HEY! You refreshed the page, didn't you? Well, YOU CAN'T DO THAT. Whenever you refresh me, YOU BRAINWjavascript:validForm('save');

SaveASH ME!!";

 

}

?>

 

I know where my problem is (red section) at least I think that's it.  :shrug: What I want to happen is that depending on the option they choose in the Purchase Domain field will change what's added to the automated response email.  If yes, then the extra text is added, if no, then nothing's added.

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/198405-automated-email-extra-coding/
Share on other sites

Oh.. you need to convert that JavaScript code to PHP.

 

You need to give values to each of your input fields. Example:

Package (Required): <input type="text" name="package" value="1" /><br><br>

 

 

So for the $body, try something like: (just an example)

$body = "Hello $name, \n 
<p>
<b>PLEASE SAVE THIS AS A RECORD - READ THIS EMAIL IN FULL<b>
<p>
Thank you for choosing Ultimatum Hosting, we appreciate all the business we get and will visit your site often, not
just as a host, but as someone you can rely on.  If you are recieving this message it means we have recieved your order.
You have chosen the $package Package.  If any of this information is incorrect, please reply with the correct details
of the Package you require.
<p>
While the details of your order are being processed we must confirm that you have read the Terms on our site.  These
are very important, as breaking any of them may result in Account Suspension and eventually Termination.
<p>
You should recieve an email from paypal requesting the amount needed from email address (my other email
address).  As soon as the amount is paid in full, you will recieve an email from me with all your account details.
<p>";

$goodpackage = ($_POST['package'] === "1");
if ($goodpackage) {
     $body .= "The Package you have chosen comes with a free Domain name/You have requested a Domain name with your package. While
everything is being processed can you please send a reply with your requested Domain name so that we can order it ready for you.";
}

Wow, thanks for the quick response!

Before it was saying error on a middle line, but now it's saying there's an error right at the end.  I'm sure that to close a php line you use ;?>.

I have done and I've even tried changing it a few times but it still says there's an error.  What should I do?

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.