GetDotted Domains

Viewing Thread:
"Help (PHP)"

The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.

Sat 23/03/02 at 16:24
Regular
Posts: 787
On my new site, I've decided to have a feedback option where users can send me suggestions on how I could improve my site or give me ideas on new wallpaper themes. Thing is, I'm new to PHP and have made my own mail script. I just uploaded it to find it doesn't work.

Here is the script :-

function sendmail()
{
global $mail_to, $mail_from_name, $mail_from_email; $mail_body;

$mail_parts["mail_to"] = $mail_to;
$mail_parts["mail_from_name"] = $mail_from_name;
$mail_parts["mail_from_email"] = $mail_from_email;
$mail_parts["mail_body"] = $mail_body;

$mail_to = [email protected]

if(my_mail($mail_parts))
user_message("Successfully sent an e-mail title '$mail_subject'.");

else error_message("An unknown error occurred while attempting to send an e-mail title '$mail_subject'.");
}
function my_mail($mail_parts)
{
$mail_from = $mail_parts["mail_from_name"];
$mail_body = $mail_parts["mail_body"];

if(empty($mail_to)) error_message("Empty to field!");
if(empty($mail_body)) error_message("No message!");

$mail_to = str_replace("; ", ",", $mail_to);

$mail_headers = '';

$mail_subject = stripsplashes($mail_subject);
$mail_body = stripslashes($mail_body);

return mail ($mail_body);
}
?>

This is the page where users can send the feedback:-

http://wallpapers.mega.net.kg/feedback/

Any suggestions would be helpful, cheers.

By the way, I know the site looks complete crap on Netscape, I'm in the middle of sorting that :).
Sun 24/03/02 at 18:01
Regular
"No Surprises Please"
Posts: 2,192
Ok, I'll give that a try. Thanks a lot guys.
Sun 24/03/02 at 14:31
Regular
"It goes so quickly"
Posts: 4,083
Gabbo, sorry I should have made it a little more clear.

============================================================

mail($mail_to, "Feed Back Form Results",
"FROM: $mail_from_name ($mail_from_email) $mail_body"
", "FROM:$mail_from_email");

print "Feed back has been sent, thank you.

\n\n";

============================================================

is all you really need, none of the other code that you have written. Just copy that code into say Send_Feedback.php and it will do what you after, although right now it doesn't validate it to make sure people fill in all 3 fields, you may also want to add on more line at the bottom to link back somewhere, like:

print "You may return to my Home Page";

Sun 24/03/02 at 00:09
Regular
"Eff, you see, kay?"
Posts: 14,156
I always find that worked examples are great, but the best scripts are those written from the ground-up.
Sun 24/03/02 at 00:03
Regular
"No Surprises Please"
Posts: 2,192
I'm not too surprised. I just started hacking at the script thinking I knew what I was doing. But, I guess I'll learn something from every mistake I make.
Sat 23/03/02 at 23:59
Regular
"Eff, you see, kay?"
Posts: 14,156
Royally! You removed the single most essential part of it!
Sat 23/03/02 at 23:10
Regular
"No Surprises Please"
Posts: 2,192
It was in my PHP book. It was sort of a complex mailer to begin with, where you could add attatchments etc. I tried cutting it down, getting rid of stuff I thought I didn't need. Must of properly screwed it up whilst doing so.
Sat 23/03/02 at 22:23
Regular
"Eff, you see, kay?"
Posts: 14,156
Where the hell have you got the concept for this script from? It's nothing like anything I've seen documented, it just makes no sense. If anything, I'd say you were trying to use sendmail in PERL.

Go to www.php.net/mail , it's very self-explanatory.
Sat 23/03/02 at 17:32
Regular
"No Surprises Please"
Posts: 2,192
It's still not working :(.

This is the updated script.

function sendmail()
{
global $mail_to, $mail_from_name, $mail_from_email; $mail_body;

$mail_to = '[email protected]';

$mail_parts["mail_to"] = $mail_to;
$mail_parts["mail_from_name"] = $mail_from_name;
$mail_parts["mail_from_email"] = $mail_from_email;
$mail_parts["mail_body"] = $mail_body;

mail($mail_to, "Feed Back Form Results",
"FROM: $mail_from_name ($mail_from_email) $mail_body";
", "FROM:$mail_from_email");

print "Feed back has been sent, thank you.

";

}
function my_mail($mail_parts)
{
$mail_from = $mail_parts["mail_from_name"];
$mail_body = $mail_parts["mail_body"];

if(empty($mail_to)) error_message("Empty to field!");
if(empty($mail_body)) error_message("No message!");

$mail_to = str_replace("; ", ",", $mail_to);

$mail_headers = '';

$mail_subject = stripsplashes($mail_subject);
$mail_body = stripslashes($mail_body);

return mail ($mail_body);
}
?>

The commands you told me to insert might not be in the right place though. I don't really know what I'm doing.

Sat 23/03/02 at 17:16
Regular
"No Surprises Please"
Posts: 2,192
OK, I sort of get you. I'll have another try at getting it to work.

Thanks a lot cjh.
Sat 23/03/02 at 17:06
Regular
"It goes so quickly"
Posts: 4,083
mail($mail_to, "Feed Back Form Results",
"FROM: $mail_from_name ($mail_from_email) $mail_body"
", "FROM:$mail_from_email");

Will work fine, you can just use that bit of code to seny you the mail, you might want to add:

print "Feed back has been sent, thank you.

";

after the top bit of code.

This will just send you the feedback and put a 'thank you' on the page, but it won't validate it or anythin like you have tried to do, as I didn't really understand some of that at the bottom :o)

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

Very pleased
Very pleased with the help given by your staff. They explained technical details in an easy way and were patient when providing information to a non expert like me.
Many thanks!!
Registered my website with Freeola Sites on Tuesday. Now have full and comprehensive Google coverage for my site. Great stuff!!
John Shepherd

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.