Friday, 15 July 2011

scripting - Adding a mail to function to an already exsisting PHP script -


I have created a publishing website with PHP scripting, which allows the signer to display in my site's backoffo is . The one I am trying to accomplish is adding a matching function to the script so that they can email signatory information, and send a time stamp, IP address and user agent ID to my email address. Any help with this will be greatly appreciated how I work for PHP and how I work myself.

  & lt ;? Includes php ('database / config.php'); ('Database / database.php'); $ Err = ''; If (isset ($ _ POST ['submit'])) {$ first = addlashes (trim ($ _ POST ['first'])); $ Last = added zombies (trim ($ _ POST ['last'])); $ Glvar = addlashes (trim ($ _ POST ['glvar'])); $ Ip = release ($ _ server ['HTTP_X_FORWARDED_FOR'])? $ _SERVER ['HTTP_X_FORWARDED_FOR']: $ _SERVER ['REMOTE_ADDR']; // echo $ ip; If ($ first! = '') & Amp; ($ last! = '') & Amp; amp; ($ glvar! = '')) {$ Database = New Database (HOST, DATEBASE, USERNAME, PASSWORD) ; $ AllUsers = $ database- & gt; Select ('user', 'glove_id', '*', "glove_id = '". $ Glvar. "' '); // echo $ ip; $ Checkglow = 0; $ Checkglow = count ($ allUsers); $ UserData = array ('first_name' = & gt; $ first, 'last_name' = & gt; $ end, 'glvar_id' => gtl = $ gt; 'ip' = & gt; $ ip,); If (! $ Checkglvar) {$ database-> Insert ('user', $ userData); Mail ("info@mysite.com", "subject", "message"); Header ('location: thank you.html'); } And $ err. = '& Lt; P style = "color: red" & gt; Hey! You have already signed the petition & lt; / P & gt; '; } Else {if ($ first == '') $ err = '& Lt; P style = "color: red" & gt; Your first name is empty & lt; / P & gt; '; If ($ last == '') $ err = '& Lt; P style = "color: red" & gt; Your last name is empty & lt; / P & gt; '; If ($ glvar == '') $ err = '& Lt; P style = "color: red" & gt; Your GLVAR ID is empty & lt; / P & gt; '; }}    

  mail ("info@mysite.com", "topic ", "message");   

You can create a "topic" and "message", think about what you want to be in the email as 3 fields ("To:", "Topic Line", "Email content").

So you can create a variable that can be emailed to you:

  $ message = "IP: $ ip" PHP_EOL; $ Message = "TIME:" Date ('Y-M-DH: I: S'); $ Message = "UserAgeent: $ Gluver_ID" PHP_EOL; Mail ("to@me.com", "subject to email", $ message);   

This looks like an email to you: subject: email subject matter: IP: 127.0.0.1 time: 2013-06-21 12: 30: 12 User Agent: Whatever may be -

By the way, I do not know what that means for you through user agent id, so I used $ glvar_id UserAgent, But I suspect that this is correct

No comments:

Post a Comment