soheils
soheils

Reputation: 53

php mail form doesn't send email and results in 404 error

my php mail form works correctly in local host(it doesn't send anything of course, but no error is shown) . when I upload it however, clicking on submit button results in a 404 page being opened as a new tab. when I send it empty, there is no error. but if I put data in it I get error.
here is the code:

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 />" . $noml . "<br/>" . $sphl . "<br/>" . $cyll . "<br/>" . $angl . "<br />" . $addl . "<br />" . $dial . "<br />" . "0" . "<br />" . "0" . "<br />" . "0" . "<br />" . "0" . "<br />" . "0" . "<br />" . "0" . "<br />" . "0" . "<br />" . "0" . "<br />" . "0" . "<br />" . "0" . "<br />" . "0" . "<br />" . "0" . "<br />" . "0" . "<br />" . "0" . "<br />" . "0" . "<br />" . $desc . "<br />"  . "<br />" . $type . "<br />" . $matter . "<br />" . $color . "<br />";
        $email = '';
        $headers  = 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
        $email= '';
        mail ( "" , $email , $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' name='email' 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='تایید اطلاعات'/>";
    }


thanks
edit:if you want to see for yourselves here is the link http://toosoptic.ir/%D9%81%D8%B1%D9%85-%D8%B3%D9%81%D8%A7%D8%B1%D8%B4-%D8%A2%D9%86%D9%84%D8%A7%DB%8C%D9%86/

Upvotes: 0

Views: 294

Answers (2)

MueR
MueR

Reputation: 977

The first parameter to the mail command is the "to" address. You're leaving it empty. See https://www.php.net/manual/en/function.mail.php

Upvotes: 0

ProllyGeek
ProllyGeek

Reputation: 15856

Action page is missing ! you should supply the php page within action attribute.

<form action="yourpage.php" method="post">

Upvotes: 1

Related Questions