Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7028903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:28:05+00:00 2026-05-28T00:28:05+00:00

I have a PHP form that I’ve set up with a POST method. When

  • 0

I have a PHP form that I’ve set up with a POST method. When all the fields aren’t filled out I have a Javascript alert box that pops up and states ‘Please fill out all fields!’ When I click ‘OK’ on the alert window it reloads the form behind it clearing all the data that was entered. Is there a function that can keep the alert box’s OK button from reloading the entire page? Here’s my code:

<?php

if (isset($_POST['brandname']) && isset($_POST['firstname']) && isset($_POST['lastname']) && isset($_POST['email']) && isset($_POST['website'])){
    $brandname = $_POST['brandname'];
    $firstname = $_POST['firstname'];
    $lastname = $_POST['lastname'];
    $email = $_POST['email'];
    $website = $_POST['website'];

    if(!empty($brandname) && !empty($firstname) && !empty($lastname) && !empty($email)){
        $to = 'matt@miller-media.com';
        $subject = 'Submission Form';
        $body = $firstname;
        $headers = 'From: '.$email;

        if (@mail($to, $subject, $body, $headers)){
        }
    }else{
        echo '<script type="text/javascript">
        window.alert("Please fill out all fields!")
        </script>';
        }

    }
    ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:28:06+00:00Added an answer on May 28, 2026 at 12:28 am

    You are alerting your user after posting response … in this case I would re-post the whole form again with its values set to $_POST or variables that were set using it, for example :

      <input type='text' name='brandname' value='<?php echo $_POST['brandname'];?>' />
    

    or :

      <input type='text' name='brandname' value='<?php echo $brandname; ?>' />
    

    and so on

    But in this case I recommend using client-side validation on the form (Using javascript)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a php form that gets validated through javascript. I would like to
I have a php form that uploads files, and all files work good the
I have a contact form that is being submitted, I have PHP validation all
I have a php / ajax / javascript form that I am trying to
I have a form that uses the POST method to send data. The POST
I have a PHP form that is inserting information into a database. It all
I have a php form that has a known number of columns (ex. top
I currently have a PHP form that uses AJAX to connect to MySQL and
i have a PHP contact form that submits data, and an email...: <?php $dbh=mysql_connect
(Using MySQL and PHP) I have a search form that will allow my users

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.