FRIHOSTFORUMSSEARCHFAQTOSBLOGSCOMPETITIONS
You are invited to Log in or Register a free Frihost Account!


e-mail error *sigh*





m-productions
I dont get why this dosnt work

Code:

<?php


$name = $_POST['name'];
$email = $_POST['email'];
$feedback = $_POST['feedback'];
sendEmail()




function sendEmail(){
   $yourname = "Feedback from ".$GLOBALS['name'];
   $youremail = $GLOBALS['email'];
   
   //to user
   $headers = "From: $yourname <$youremail>\n";
   $headers .= "Reply-To: $yourname <$youremail>\n";
   $headers .= "MIME-Version: 1.0\n";
   $headers .= "Content-type: text/html; charset=iso-8859-1";
   
   
   //the message body
   $message = "Dear ".$GLOBALS['name'].",<p> Thank you for registering your password is ".$GLOBALS['feedback']."</p>";
   
   
   mail(admin@m-productions.frih.net, "Your login details", $message, $headers);
}

?>


I get this error...

Parse error: syntax error, unexpected T_FUNCTION in /home/mproduct/domains/m-productions.frih.net/public_html/feedback.php on line 12
carcasskind
EDIT: Hangon, maybe you need to add a ; to the end of the function sendEmail()...

I can't answer your question because I don't code natively in PHP, but I do use a mailing script when I need one, it might come in useful as a comparison:

Code:

<?php

/***** BEGIN CONFIGURATION HERE *****/
//Replace the URL below with the URL to your "Mail Sent Successfully" Page
header("Location: http://www.yoursite.com/success.htm");
 
$to_name = "You!"; //enter the name of the recipient
$email_to = "your@email.com"; //enter the email address of the recipient
$site_name = "YourWebsite.net"; //enter the name of your website
$subject = "Subject"; //enter the subject
/***** END SCRIPT CONFIGURATION *****/

//do not edit below this line
mail("$email_to", "$subject", "
ATTENTION: " . $to_name . ",\n"
 .
"The following message was sent to you from the ".$site_name." Contact Form by:\n"  .
"Name: " . $_POST['name'] .
"\nE-mail: " . $_POST['email'] . 
"\nIP: " . $REMOTE_ADDR .

"\n\nThis is the message:\n" .
$_POST['message'] .

"\n\n From: " . $_POST['name'] . " <" . $_POST['email'] . ">\nReturn-path: " . $_POST['email'] .
"\n\n\nSent from YourSite.com")


?> 


It's meant to be used with some kind of form, be it html/flash or whatever.

The values for name, email and ip are passed by the form. You can do the same for others if you want, just needs editing. Hope it helps Smile
Stubru Freak
m-productions wrote:
Code:

<?php


$name = $_POST['name'];
$email = $_POST['email'];
$feedback = $_POST['feedback'];
sendEmail();

...


I get this error...

Parse error: syntax error, unexpected T_FUNCTION in /home/mproduct/domains/m-productions.frih.net/public_html/feedback.php on line 12


You forgot a semicolon after sendEmail()
Manofgames
I'd also suggest the smicolon, and if that doesn't work, try passing the variables to the function rather then using globals.

Try this:
Code:


<?php
sendEmail($_POST['name'], $_POST['email'], $_POST['feedback']);




function sendEmail($name, $email, $feedback){
   $yourname = "Feedback from ".$name;
   $youremail = $email;
   
   //to user
   $headers = "From: $yourname <$youremail>\n";
   $headers .= "Reply-To: $yourname <$youremail>\n";
   $headers .= "MIME-Version: 1.0\n";
   $headers .= "Content-type: text/html; charset=iso-8859-1";
   
   
   //the message body
   $message = "Dear ".$name.",<p> Thank you for registering your password is ".$feedback."</p>";
   
   
   mail(admin@m-productions.frih.net, "Your login details", $message, $headers);
}

?>


also, you might want to add \n instead of <p> because not everyone recieves mail in html Wink
fromegame
Hehe, I would first enter the function and then call it Razz
Manofgames
as far as I know, with PHP 4-5+ (Can't remember which) you can call a function before it exists.
m-productions
yep adding the ; was all i needed (and then I needed to add " " arround the address) thanks for the help
Related topics
Australian state to ban workplace e-mail spying
Web e-mail !
Neat e-mail account
Play bay E-Mail (PBeM)
e-mail problems
Longest domain name in the world!
[RESOLVED]OK, so l've noticd that e-mail takes space...
e-mail
e-mail
E-mail me button help
[suporte] E-mail não envia e não recebe???
My E-mail Has Never Worked.
Sorry......E-mail not working
Setting up E-mail Problems
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.