简体   繁体   中英

php mail form doesn't send mail


I seem to have a problem with an email form I am making.
the form worked correctly until I added some extra parts to it. however, even when I comment my changes, it won't work.
I thought the problem might be due to some syntax error, but It doesn't seem to be so.
I do not get any error message
below is my code:

<?php
if(isset($_REQUEST['email'])) {
    $num=$_REQUEST['num'];
    $desc=$_REQUEST['desc'];
    $subject="einak";
    $nomr=$_REQUEST['nomr'];
    $sphr=$_REQUEST['sphr'];
    $cylr=$_REQUEST['cylr'];
    $angr=$_REQUEST['angr'];
    $addr=$_REQUEST['addr'];
    $diar=$_REQUEST['diar'];
    $noml=$_REQUEST['noml'];
    $sphl=$_REQUEST['sphl'];
    $cyll=$_REQUEST['cyll'];
    $angl=$_REQUEST['angl'];
    $addl=$_REQUEST['addl'];
    $dial=$_REQUEST['dial'];
    $type=$_REQUEST['type'];
    $matter=$_REQUEST['matter'];
    $color=$_REQUEST['color'];
    $message=$num."<br />".$nomr."<br/>".$sphr."<br/>".$cylr."<br/>".$angr."<br />".$addr."<br />".$diar."<br />"."<br />".$noml."<br/>".$sphl."<br/>".$cyll."<br/>".$angl."<br />".$addl."<br />".$dial."<br />".$desc."<br />".$type."<br />".$matter."<br />".$color."<br />";
    $email='info@toosoptic.ir';
    $headers='MIME-Version: 1.0'."\r\n";
    $headers.='Content-type: text/html; charset=iso-8859-1'."\r\n";
    mail("mail@example.com",$subject,$message,$headers);
    echo "ارسال شما موفقیت آمیز بود";
} else {
    echo "<form method='post'>
                <input name='num' id='num' type='text' /> <br />
                <input type='text' name='nomr' id='nomr' > <br />
                <input type='text' name='sphr' id='sphr'> <br />
                <input type='text' name='cylr' id='cylr'  > <br />
                <input type='text' name='angr' id='angr'  > <br />
                <input type='text' name='addr' id='addr'  > <br />
                <input type='text' name='diar' id='diar' > <br />
                <input type='text' name='noml' id='noml' > <br />
                <input type='text' name='sphl' id='sphl'> <br />
                <input type='text' name='cyll' id='cyll'  > <br />
                <input type='text' name='angl' id='angl'  > <br />
                <input type='text' name='addl' id='addl'  > <br />
                <input type='text' name='dial' id='dial' > <br /> 
                <textarea id='desc' name='desc'> </textarea>          
                <input name='type' type='radio' value='bifocal' id='type1' />
                <input name='type' type='radio' value='progres' id='type2' />
                <input name='type' type='radio' value='single' id='type3' />
                <input name='type' type='radio' value='decen' id='type4' />
                <input name='matter' type='radio' value='glass' id='mat1' />
                <input name='matter' type='radio' value='plastic' id='mat2' />
                <input name='color' type='radio' value='single' id='col1' />
                <input name='color' type='radio' value='decen' id='col2' /> 
                <input type='submit' id='sb' value='ارسال اطلاعات' />
                <input type='text' name='name' id='name'  > <br />
                <input type='add' name='address' id='address'  > <br /> 
            </form >
            <p id='confirmation'></p>
            <input  type='submit'  id='vis' onClick='vis(); return false;'  value='تایید اطلاعات'/>";
}
?>

You have not define the name in the submit button here:

 <input type='submit' id='sb' value='ارسال اطلاعات' />

Replace above code with the below code:

 <input type='submit' id='sb' name='email' value='ارسال اطلاعات' />

You are checking the code if(isset($_REQUEST['email'])) and there is no email field the form as I see.

Basically this check is used for verifying that form have submitted or not(as generally other do). So you need to add the name='email' in the submit button attribute to execute the if condition code..

您正在设置mime标头,但您没有设置任何mime编码,这可能是一个问题;-)尝试使用专用软件包,如PEAR / Mail (和PEAR / Mail / Mime )或phpMailer

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM