0

UPDATE: non of any php files is running. Is there a way to solve the problem ?

I have html a page that takes the email details:

    <form method="POST" sourceindex="44" action="semail.php" name="form1" onSubmit="return validate_form ( );">
        <p>
          <label>Your name:<br>
            <input sourceindex="47" name="mail_name" class="text_field" type="text">
          </label>
        </p>
        <p>
          <label>Your e-mail:<br>
            <input sourceindex="51" name="mail_email" 
class="text_field" type="text">
          </label>
        </p>
        <p>
          <label>Message:<br>
            <textarea sourceindex="55" name="mail_msg" cols="45" 
rows="5" class="text_area"></textarea>
          </label>
        </p>
        <input name="B1" type="submit" class="form_button" value="" />
      </form>

and here is the php code (this is all in semail.php):

     <?php
$mail_to ="someEmail@hotmail.com";
$mail_subject = "Message From a Customer";
$mail_body ="Name of the Coustomer: ".$_POST['mail_name']."\n";
$mail_body .= "E-Mail Of the Coustomer: ".$_POST['mail_email']."\n";
$mail_body .= "The Message: ".$_POST['mail_msg']."\n";
if(mail($mail_to, $mail_subject, $mail_body))
echo "Thanks for your Message";
else 
echo "Failed to send the e-mail"
 ?>

Whenever I click send the semail.php page shows me this error: No input file specified Can someone help me please in figuring out where is the problem ?

Maher Nabil
  • 1,417
  • 1
  • 15
  • 19
  • can you add a ; at the end of echo "Failed to send the e-mail" and see if it works – Satya Sep 15 '13 at 06:22
  • 1
    Possibly a duplicate? Even the coding is different, the problem is the same. – mathielo Sep 15 '13 at 06:23
  • Satya: is already there. mathielo: I tried it but it didn't work. any other suggestions what the error might be ? – Maher Nabil Sep 15 '13 at 06:28
  • @Satya, you don't need `;` for the last instruction just before closing `?>`. The actual use of semicolon is to distinct different instructions from each other, so if you don't have any more instructions and close php's tag, you won't have a problem. Nevertheless, I prefer to always use them, even for short instructions such as ``. – mathielo Sep 15 '13 at 06:28
  • where is send mail button in your form ? verify the path of semail.php is correct in action – Shafeeque Sep 15 '13 at 06:35
  • Shafeeq: it's in html page where the form is and it is correct since the www.site.com/semail.php is opened but with that error !! – Maher Nabil Sep 15 '13 at 06:44
  • @MaherNabeel This problem may not be related to `semail.php`'s code itself. Do any other `.php` file works in the same directory? Also, if you have an `.htaccess` post here what's in it. – mathielo Sep 15 '13 at 06:56
  • @mathielo: you're right. non of any php file is working. how to solve this ? – Maher Nabil Sep 15 '13 at 07:08
  • and also there isn't anything in .htaccess file. – Maher Nabil Sep 15 '13 at 07:11
  • @MaherNabeel Where is this PHP file hosted? local or on a web server? Looks like this message is an "uglier" 404 generated by PHP's interpreter, when it tries to read a file that it "thinks" that exists. Are you sure the path to the file is correct? No other `.htaccess` files on parent directories? (`.htaccess` works recursively through directories) – mathielo Sep 15 '13 at 07:22
  • @mathielo the file is hosted on webserver. I discovered that no php file on the website ? what should I do ? – Maher Nabil Sep 15 '13 at 07:41
  • @MaherNabeel In that case I think you should contact your hosting company as this seems to be a server-related issue. I can't tell you exactly _how_ to fix it, but I bet only them can do it, unless you have a dedicated server or so. – mathielo Sep 15 '13 at 07:48
  • Hey @MaherNabeel, did you solve your problem? – mathielo Sep 17 '13 at 13:54
  • @mathielo not yet. the problem it seems from the hosting company not from the code above. – Maher Nabil Sep 18 '13 at 14:58
  • @MaherNabeel yeah, they should solve this one for you. Give us a feedback later, and if possible tell us what they did to correct that. – mathielo Sep 18 '13 at 16:30

1 Answers1

1

To first check and verify that PHP is running and available with the present Web hosting company, create a file called check_server.php and insert the following code:

<?php

// Show all information, defaults to INFO_ALL
phpinfo();

// Show just the module information.
// phpinfo(8) yields identical results.
phpinfo(INFO_MODULES);

?>

If successful, you will see your server information and configurations. It will also show the path to mail.

Regarding your form code:

My answer may or may not solve a probable Hosting company issue, however there were a few errors in your code which would result as unsuccessful.

Please read the following:

In using the following form, had success in sending and receiving the message.

<form method="POST" sourceindex="44" action="semail.php" name="form1">
<p>
<label>Your name:<br>
<input sourceindex="47" name="mail_name" class="text_field" type="text">
</label>
</p>
<p>
<label>Your e-mail:<br>
<input sourceindex="51" name="mail_email" 
class="text_field" type="text">
</label>
</p>
<p>
<label>Message:<br>
<textarea sourceindex="55" name="mail_msg" cols="45" 
rows="5" class="text_area"></textarea>
</label>
</p>
<input name="B1" type="submit" class="form_button" value="Submit" />
</form>

N.B.: I do need to point out that your PHP mail handler did not contain a few required elements.

For example the From: element/variable which was not present in your handler.

$mail_email= $_POST['mail_email'];

Also headers were not present. Mail requires 4 variables to send/receive Email.

For example you have if(mail($mail_to, $mail_subject, $mail_body))

Which should read as if(mail($mail_to, $mail_subject, $mail_body, $headers))

Omitting the headers would result in a message marked as SPAM because of the missing Email from and would show as unknown sender

In conjunction with the form above, am including a working copy of the PHP mail handler:

<?php
$mail_to ="someEmail@hotmail.com";
$mail_email= $_POST['mail_email'];
$mail_subject = "Message From a Customer";

$mail_body ="Name of the Customer: ".$_POST['mail_name']."\n";
$mail_body .= "E-Mail Of the Coustomer: ".$_POST['mail_email']."\n";
$mail_body .= "The Message: ".$_POST['mail_msg']."\n";

$headers = "From: $mail_email \r\n";
$headers .= "Reply-To: $mail_email \r\n";

if(mail($mail_to, $mail_subject, $mail_body, $headers))

echo "Thanks for your Message";
else 
echo "Failed to send the e-mail";
?>
Community
  • 1
  • 1
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141