Email notification when user submits using addForm.php

15 posts by 4 authors in: Forums > CMS Builder
Last Post: June 4, 2012   (RSS)

Re: [Jeffncou] Email notification when user submits using addForm.php

By Jason - September 27, 2010

Hi,

Try using this code below where you add information to the database:

$to="your_email@domain.com";
$subject="New Contact Added";
if(@$_REQUEST['newsletter_sign_up']){$_REQUEST['newsletter_sign_up']=1;}else{$_REQUEST['newsletter_sign_up']=0;}
$message=<<<__TEXT__
A new contact was added:

title:{$_REQUEST['title']}
position:{$_REQUEST['position']}
company_name:{$_REQUEST['company_name']}
type_of_business:{$_REQUEST['type_of_business']}
telephone:{$_REQUEST['telephone']}
email:{$_REQUEST['email'] }
address:{$_REQUEST['address']}
postcode:{$_REQUEST['postcode']}
country:{$_REQUEST['country'] }
area_of_interest:{$_REQUEST['area_of_interest'] }
newsletter_sign_up: {$_REQUEST['newsletter_sign_up']}
__TEXT__;

mail($to,$subject,$message);


You can change the value of $to to be whatever email address you want the message sent to.
It's important to note that the line __TEXT__; that's at the end of the message must be flush against the left hand side of your page. If there are any spaces, it will cause an error.

Give that a try.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Email notification when user submits using addForm.php

By JeffC - September 27, 2010

Hi Jason

Thanks for the response. Can you explain what you mean by 'after I add code to the database'. I have tried putting it directly after:

// submit form
if (@$_REQUEST['submit']) {


but it returns a syntax errors
Jeff

Re: [Jeffncou] Email notification when user submits using addForm.php

By Jason - September 27, 2010

Hi,

Try putting this code after this line:
$recordNum = mysql_insert_id();

What are the syntax errors you're receiving?

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Email notification when user submits using addForm.php

By JeffC - September 27, 2010

HI Jason

I have put the code where you suggest and get the following error

Parse error: syntax error, unexpected T_SL in /home/jeffncou/public_html/thegrandtour.eu/addForm.php on line 41
Jeff

Re: [Jeffncou] Email notification when user submits using addForm.php

By Jason - September 27, 2010

Hi,

Try replacing the $message variable with this?

$message=<<<__TEXT__
A new contact was added:

title:{$_REQUEST['title']}
position:{$_REQUEST['position']}
company_name:{$_REQUEST['company_name']}
type_of_business:{$_REQUEST['type_of_business']}
telephone:{$_REQUEST['telephone']}
email:{$_REQUEST['email'] }
address:{$_REQUEST['address']}
postcode:{$_REQUEST['postcode']}
country:{$_REQUEST['country'] }
area_of_interest:{$_REQUEST['area_of_interest'] }
newsletter_sign_up: {$_REQUEST['newsletter_sign_up']}

__TEXT__;


Again, make sure the __TEXT__; is right at the far left.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Email notification when user submits using addForm.php

By JeffC - September 27, 2010

Still no joy i'm afraid.
Jeff

Re: [Jeffncou] Email notification when user submits using addForm.php

By Jason - September 27, 2010

Hi,

If you could email your CMS login and FTP details to jason@interactivetools.com, I'll take a closer look.

Only email this information don't post it to the forum.

Thanks.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jeffncou] Email notification when user submits using addForm.php

By Jason - September 27, 2010

Hi Jeff,

I've got it fixed. What was happening is there was a blank space after "$message=<<<__TEXT__" that was causing the error, which is pretty hard to spot. Give it a try, it should be working for you now.


Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Email notification when user submits using addForm.php

By design9 - May 21, 2012

Can you tell me what fields need to go here:

if(@$_REQUEST['newsletter_sign_up']){$_REQUEST['newsletter_sign_up']=1;}else{$_REQUEST['newsletter_sign_up']=0;}


I do not have a newsletter sign up field. I am using title, name, description, email and upload. Trying to add a email notification to myaddForm.php as well that lets me know when a form has been submitted.

thank you,
April