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 7029393
In Process

The Archive Base Latest Questions

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

(Sorry for my bad english) Well, I’ve 3 errors in my code. Error’s: First

  • 0

(Sorry for my bad english)

Well, I’ve 3 errors in my code.

Error’s:

  1. First of all it’s show : Notice: Undefined index: form in C:\xampp\htdocs\evantechbd\index.php on line 461. When i run this form.
  2. if any error found it’s show error message, well, but correct field is empty. Example: In this form there is 4 fields. a) upload image, b) select discussion c) subject and d) message. Suppose you upload a image, select a discussion and write a subject but forgot to write message. Then It’s show “Message Required” and every filed is empty. I don’t want empty field which is correct.
  3. After successfully submitted the form it’s show “Discussion was submitted “. But after that if i refresh the page it’s send the data to database. But I did not click submit button. why this happen?

Here is my code:

<?php
if ($_POST['form'] == "Submit") {
    $err       = array();
    $filed     = addslashes($_FILES['file']['tmp_name']);
    $img_named = addslashes($_FILES['file']['name']);
    $img_type  = addslashes($_FILES['file']['type']);
    @$imgd = addslashes(file_get_contents($_FILES['file']['tmp_name']));

    function getExtension($str)
    {
        $i = strrpos($str, ".");
        if (!$i) {
            return "";
        }
        $l   = strlen($str) - $i;
        $ext = substr($str, $i + 1, $l);
        return $ext;
    }
    $extension        = getExtension($img_named);
    $extension        = strtolower($extension);
    $image_named_uniq = uniqid() . '.' . $extension;
    $upload_path_dis  = 'user/manage/discussionimg/';

    $diss = $_POST['type'];
    $sub  = $_POST['sub'];
    $msg  = $_POST['msg'];
    $date = "On " . date("F Y h:i:s A");

    if (!isset($_SESSION['uname']))
        $err[] = "You need to login";

    else {
        $uname = $_SESSION['uname']; //session username

        if (empty($sub) && empty($msg) && empty($filed))
            $err[] = "All field required";
        else {
            if (empty($sub))
                $err[] = "Subject Requried";

            if (empty($msg))
                $err[] = "Message Requried";

            if (empty($filed))
                $err[] = "SORRY, you have to be upload a image";
        }
    }

    if (!empty($err)) {
        foreach ($err as $er) {
            echo "<font color=red>$er</font><br/>";
        }
    }

    else {
        $sql = mysql_query("INSERT INTO discussion VALUES ('', '$imgd', '$image_named_uniq', 
'$diss', '$sub', '$msg', '$uname', '$date' ) ");
        if (!$sql)
            echo "Can't submit your discussion" . mysql_error();

        if (!move_uploaded_file($_FILES['file']['tmp_name'], $upload_path_dis . $image_named_uniq)) {
            die('File Not Uploading');
        } else {
            echo "Discussion was submitted";
        }
    }
}
?>

Many Thanks for your help!!
Kanta.

  • 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:32:00+00:00Added an answer on May 28, 2026 at 12:32 am
    1. Try changing your first if condition as follows

      if (isset($_POST['submit']))

    2. Now most of web sites uses client side validations using javascript. You can use jquery frame work to make things easier. However since you already uses validations after the POST event. You have to set values to relevant fields as bellow code. It will set tha value of the subject.

      <input type="text" name="sub" value="<?php if(isset($_POST["sub"])) echo $_POST["sub"]; ?>" size="46"/>

    3. Yes if you refresh the code it will again do the post and insert. You have to do few controls. However these things depend on your data.

    a. Make unique key indexes in the database

    b. Check for existing record before the insertion.

    c. Redirect your page to the same page after few seconds once the user see the successful message.

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

Sidebar

Related Questions

first of all sorry by my bad english, Hello i am new in this
First, sorry for bad english :-) On a little website i own, i would
first,sorry for my bad English!! i'm new here and i'm a beginner of android
sorry for bad English. It's Ruby code. s = мистика `touch #{s}` `cat #{s}`
(first, sorry for my bad english, i'm a beginner) I have a chart of
First. Sorry for bad english. I want to make some common transformation of Map
Sorry for bad English :( Suppose i can preliminary organize recipes and ingredients data
Hello (Sorry for my bad English) Is it bad practice to assign object to
Sorry for bad english. bfproduct is a table and productid is primary key in
In relation to my first question Show recipe name if all of its ingredients

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.