Wednesday, 15 May 2013

forms - PHP function call was ignored? -



forms - PHP function call was ignored? -

i have frustrating problem occuring in php code. there no reported errors , seems work correctly, except 1 time function phone call made seems not work. using mail() function send out e-mail grab , save .eml file test mail service server tool. here code leading function call:

if(!empty($email)) { if(filter_var(trim($email), filter_validate_email)) { composeemail($email, $name, $idnumber, $othername); } }

i did standard debugging techniques , outputted value of variable within if statement create sure there value beingness passed parameter, , returned value correctly. real issue when reach composeemail() function.

function composeemail($email, $name, $id, $othername) { echo ($email); $to = "$email"; $subject = 'confirmation'; $txt = 'body text goes here'; $headers = 'mime-version: 1.0' . "\r\n"; $headers = 'content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers = 'from: donotreply@sampleweb.net' . "\r\n"; mail($to, $subject, $txt, $headers); }

some parameters aren't used in code because took out utilize in body text post example. have test form function , works perfectly. function called , test mail service server tool receives e-mail , saves it. output of e-mail within function doesn't output anything.

i checked logic errors, checked create sure variable has value, , pretty much can think of. suggestions/ideas?

composeemail($email, $name, $idnumber, $othername) and composeemail($email, $name, $id, $othername) - you're using different id variables.

plus, you're missing concatenates 2nd , 3rd headers.

echo ($email); $to = "$email"; $subject = 'confirmation'; $txt = 'body text goes here'; $headers = 'mime-version: 1.0' . "\r\n"; $headers .= 'content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'from: donotreply@sampleweb.net' . "\r\n"; mail($to, $subject, $txt, $headers);

that's why headers broken.

plus, comments left under question, should speak , don't sense should repeat them here.

this 1 has proven grouping effort. if else have contributed solution , cares add together answer, happy upvote.

php forms email

No comments:

Post a Comment