Page 1 of 1

New to PHP, code is not working

Posted: Tue Jan 11, 2011 8:04 am
by wayneio
Hi there,

I am new to PHP, and this forum. I have attempted to create my first very basic PHP script, simply to mail a form, however when i try to run it, all i get is a blank page with no email.

My server (freehostia chocolate account) says it supports PHP.
The files are at: http://www.waynecovell.co.uk/form.html
and: http://www.waynecovell.co.uk/sendmail.php

Anyone shed light into a noobs world of PHP?
Thanks in advance

Re: New to PHP, code is not working

Posted: Tue Jan 11, 2011 8:16 am
by Benjamin
Welcome :)

Blank page is a parse error. You'll want to enable error reporting.

Put this at the top of your code:

Code: Select all

error_reporting(E_ALL);
ini_set('display_errors', true);

Re: New to PHP, code is not working

Posted: Tue Jan 11, 2011 8:28 am
by wayneio
Ah thanks for that. Now I get the error
Fatal error: Call to undefined function remove_headers() in /home/www/waynecovell.co.uk/sendmail.php on line 13
I read a tutorial that, remove_headers() is what you should do for mailing a form. As this is causing the error, should I try just removing the remove_headers from the code?


EDIT: Okay, so I did remove those. and it worked. now i get these errors:
Notice: Undefined index: Option1 in /home/www/waynecovell.co.uk/sendmail.php on line 21

Notice: Undefined index: Option2 in /home/www/waynecovell.co.uk/sendmail.php on line 22

Warning: mail() expects at most 5 parameters, 14 given in /home/www/waynecovell.co.uk/sendmail.php on line 30
I understand the last one means i can only email 5 parameters, but how do people get around this?
And i simply do not understand why the others are undefined?

Re: New to PHP, code is not working

Posted: Tue Jan 11, 2011 10:54 am
by social_experiment
wayneio wrote:I understand the last one means i can only email 5 parameters, but how do people get around this?
No this means that the mail() function expects only 5 parameters (arguments). This is from the PHP Manual:
bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )
You can get around it (send mail to multiple users) by using loops or arrays. Please post your script :)
Hth