Jump to content

Check if a file is selected (contact form)


rj28kl

Recommended Posts

Hi,

I have a beginner question for PHP and maybe you hand help me easily. I have a contact form where a user should select a file to upload. I have insert this in the form with:

<tr>
  <td>Please attach here your <br>1-Hour-Energy-Audit Excel file:</td>
  <td><input name="Anhang" size="20" type="file"></td>
</tr>
<tr>

 

When the form is send, I check allready the fields email address and name with:

if($_REQUEST['Send'])
{
    if(empty($_REQUEST['Name']) || empty($_REQUEST['Email']))
    {
        echo"Please <a href=\"javascript:history.back();\">go back</a> to the contact form to fill out all fields. Thank you";
    }

 

I had tried to check the attachment field with:

if($_REQUEST['Send'])
{
    if(empty($_REQUEST['Name']) || empty($_REQUEST['Email']) || empty($_REQUEST['Anhang']))
    {
        echo"Please <a href=\"javascript:history.back();\">go back</a> to the contact form to fill out all fields. Thank you";
    }

but that did not work out. I can select a file (path), but I got still the message to fill out all fields. How can I check if a path is selected (or something is in the field) when the user clicks on the send button?

Is there an easy solution for a beginner in PHP? Just to have this form work?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.