How can i clear the form data

It will sending the previously uploaded file whwn i refresh the page how to make the form not to send when i refresh the form.

<form method=”POST” enctype=”multipart/form-data”>
<h1>Career</h1>
<label style=”padding-right:20%;”>Name:<span style=”color:red;”> *</span></label> <input type=”text” name=”names” style=”width:200px;”required >

<br><br>
<label style=”padding-right:145px;”>E-mail: <span style=”color:red;”>*</span></label> <input type=”email” name=”email” style=”width:200px; “required>

<br><br>
<label style=”padding-right:70px;”>Desired Location:<span style=”color:red;”>*</span></label><select name=”location” style=”width:200px; height:30px;”>
<option value=”Taipei” selected>Taipei, Taiwan</option>
<option value=”Malaysia” >Kuala-Lumpur, Malaysia</option>
<option value=”Bangalore” >Bengaluru, India</option>
<option value=”Kokomo” >Kokomo, USA</option>
<option value=”offsite” >Offsite/Work from Home</option>
</select>

<br><br>
<label style=”padding-right:80px;”>Desired Position:</label>
<input type=”text” name=”position”>
<br><br>
<label style=”padding-right:40px;”>Experience (in Year):<span style=”color:red;”>*</span></label>
<input type=”number” name=”exper” min= “0” mac=”100″ required>

<br><br>
<label style=”padding-right:80px;”>Upload resume:<span style=”color:red;”>*</span></label>
<input type=”file” name=”my_file[]” accept=”.pdf” multiple=”multiple” required >

<br><br>
<input type=”submit” value=”submit” name=”submit”>
</form>

<?php
$nameErr=””;
if(isset($_POST[“submit”]))

{echo “Send”;
$loc = $_POST[“location”];
$uploaddir = ‘C:xampptmp’;
$myFile = $_FILES[‘my_file’];
$fileCount = count($myFile[“name”]);
for ($i = 0; $i < $fileCount; $i++) {
$uploadfile = $uploaddir . basename($_FILES[‘my_file’][‘name’][$i]);
if (!move_uploaded_file($_FILES[‘my_file’][‘tmp_name’][$i], $uploadfile)) {

break;
}
$attachments[$i] = $uploadfile;

}

$message .= “Name: “.$_POST[“names”].”n”;
$message.= “Email: “.$_POST[“email”].”n”;
$message .= “Location: “.$_POST[“location”].”n”;
$message .= “Position: “.$_POST[“position”].”n”;
$message .= “Experience: “.$_POST[“exper”].”n”;
$subject = “Career form”;
if($loc == “Bangalore”){
$to = ‘xxx@gmail.com’;
}
else {
echo “Could not send email”;
}
wp_mail($to, $subject, $message, $headers=”, $attachments);
$_POST = array();
echo “<br>”;
echo $_POST[’email’];
echo $_POST[‘location’];
echo $_POST[‘position’];
echo $_POST[‘exper’];

}

?>

Read more here:: How can i clear the form data

Leave a Reply

Your email address will not be published. Required fields are marked *