Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

Newbie needs help with very 'simple' script

the mail() function

Moderators: macek, egami, gesf

Newbie needs help with very 'simple' script

Postby Shaolin » Fri Mar 11, 2005 8:19 am

Hi!
I'm totally new to php and I'm trying to get a 'simple' php-script to work.
The script is supposed to send me an e-mail IF the user has answered all questions on my site AND checked all necessary radio-buttons. But even if i do all this, i get the error saying i left some questions unanswered.

Here's the code:

Code: Select all
<?php
if($submit) {
    if($name AND $email AND $text1 AND $text2 AND $radio1 AND $radio2 AND $radio3 AND $radio4 AND $radio5 AND $radio6 AND $radio7 AND $text3 AND $from) {
       $name;     // inneholder navnet på avsender
       $email;    // inneholder avsenders epost-adresse
       $text1;  // inneholder avsenders beskjed til deg
   $text2;  //tekstfelt
   $radio1; //jjj
   $radio2;
   $radio3;
   $radio4;
   $radio5;
   $radio6;
   $radio7;
   $text3;
   $receiver = "monagullbekkhansen@hotmail.com";
       $subject = "Mail sent from my site";
       $from = "From: $name <$email>";
           
        if(mail($receiver,$subject,$text1,$text2,$radio1,$radio2,$radio3,$radio4,$radio5,$radio6,$radio7,$text3,$from)) {
            echo "The email was sent";
        }
    } else {
        echo "The email cannot be sent because you left some questions unanswered";
    }
} else {
    echo "This page contains a mail-script. You have arrived here without using this mail-script";
}
echo "<a href=\"index.html\">Back</a>";
?>


Would really appreciate all help you guys can give me

Thanks
Shaolin
New php-forum User
New php-forum User
 
Posts: 2
Joined: Fri Mar 11, 2005 8:12 am

Postby Shiv » Fri Mar 11, 2005 9:19 pm

You should write what error you get so one can troubleshoot the problem.
:)
User avatar
Shiv
php-forum Active User
php-forum Active User
 
Posts: 262
Joined: Wed Feb 02, 2005 8:06 pm
Location: Ahmedabad (Gujarat), INDIA

Postby victor123 » Sun Mar 13, 2005 12:20 pm

Hi,

I guess the code there has some parentheses left. Besides, as a way of backtracing the problem, you can echo $variable to see the value. Try echoing all the values that have to be correctly filled to be sure. It happens to me all the time.

Cheers.
victor123
New php-forum User
New php-forum User
 
Posts: 192
Joined: Mon Sep 06, 2004 1:23 am
Location: Madrid, Spain

Postby Shiv » Sun Mar 13, 2005 7:50 pm

Have you traced the error or not??? Ok tell if any problem.
User avatar
Shiv
php-forum Active User
php-forum Active User
 
Posts: 262
Joined: Wed Feb 02, 2005 8:06 pm
Location: Ahmedabad (Gujarat), INDIA

Postby Alexej Kubarev » Mon Mar 14, 2005 12:56 am

Not a correct usage:

$name; // inneholder navnet på avsender
$email; // inneholder avsenders epost-adresse
$text1; // inneholder avsenders beskjed til deg
$text2; //tekstfelt
$radio1; //jjj
$radio2;
$radio3;
$radio4;
$radio5;
$radio6;
$radio7;
$text3;

Here comes an explanation of the possible error: register_globals = Off in PHP.ini while you are trying to use the script with them being turned on.

PLUS that you give one hell number of arguments to the mail function while it takes max 4. I still cant understand WHY you are doing this and what are you trying to achieve... anyways, i think i will explain it in swedish as well as you might understand it a bit better ;)

Ditt största problem är att du försöker ge massa argumenter till mail() funktionen medan den tar bara 4. Funktionens format är mail($to, $subject, $body, [$headers]).
den sista $headers står i [] eftersom den är inte nödvändigt men i nästan alla fall behöver du änvända den... så det är därför jag säger max 4..

Vad är det exakt som du försöker göra? kanske det kan hjälpa i fallet du läser genom PHP manualen.har du problem så kan du alltid fråga mig och så försöker jag hjälpa dig..
User avatar
Alexej Kubarev
Site Admin
Site Admin
 
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län

Postby Alexej Kubarev » Mon Mar 14, 2005 12:59 am

Oh, by the way => I am going to move this topic to php coding => Mail() forum as this is a problem of the mail function.. unless someone disagrees with me: it will stay there :)
User avatar
Alexej Kubarev
Site Admin
Site Admin
 
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län

Postby Shaolin » Mon Mar 14, 2005 7:13 am

Thanks guys for all the help. I finally figured it out. And I honestly don't know what I was doing with all those arguments :D
Shaolin
New php-forum User
New php-forum User
 
Posts: 2
Joined: Fri Mar 11, 2005 8:12 am


Return to PHP coding => Mail

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.