Sunday 15 April 2012

scripting - PHP script is having trouble sending email correctly -


I have my scripting below for my submission form. I am getting an email, but it contains all IP address and time stamp . I have not found any other information listed. I am very new to PHP, so any help would be greatly appreciated. In addition, in the email, it is calling from d91b8401 , d91b8401@p3nlhg1159.shr.prod.phx3.secureserver.net . Is that the correct way?

  & lt ;? Php included ('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); $ Message = "first name: $ first"; $ Message = "last name: $ last"; $ Message = "GLVR ID: $ glover"; $ Message = "IP: $ IP" PHP_EOL; $ Message = "TIME:" Date ('Y-M-DH: I: S'); Mail ("info@lvrealestateagentssignthepetition.com", "new petition signer", $ 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; '; }}? & Gt;    

you . = is required to use the message, you are just changing it with each assignment.

  $ message = "First name: $ first"; $ Message = "Last name: $ last"; $ Message = "GLVAR id: $ glvar"; $ Message = "IP: $ IP" PHP_EOL; $ Message = "TIME:" Date ('Y-M-DH: I: S');   

You can change the address from to: with this address:

  Mail ("info@lvrealestateagentssignthepetition.com", "New petition signer", $ message, "From: yourname@yourdomain.com");   

The fourth argument is an optional header, which overrides the default header.

No comments:

Post a Comment