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

  • Home
  • SEARCH
  • 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 6763955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:32:15+00:00 2026-05-26T14:32:15+00:00

<?php if (isset($_POST[‘first’]) && isset($_POST[‘second’]) && isset($_POST[‘submit’]) && $_POST[‘DDL’] == "+") { $equals =

  • 0
<?php

if (isset($_POST['first']) && isset($_POST['second']) && isset($_POST['submit']) && $_POST['DDL'] == "+")
{
    $equals = $_POST['first'] + $_POST['second'];
}
if (isset($_POST['first']) && isset($_POST['second']) && isset($_POST['submit']) && $_POST['DDL'] == "-")
{
    $equals = $_POST['first'] - $_POST['second'];
}
if (isset($_POST['first']) && isset($_POST['second']) && isset($_POST['submit']) && $_POST['DDL'] == "*")
{
    $equals = $_POST['first'] * $_POST['second'];
}
if (isset($_POST['first']) && isset($_POST['second']) && isset($_POST['submit']) && $_POST['DDL'] == "/")
{
    $equals = $_POST['first'] / $_POST['second'];
}

print $_POST['DDL']; // THIS IS THE LINE THAT RESULTS IN THE ERROR! WHY?

?>

<html>
<body>

<form method="post">

<input type="text" name="first">

<select name="DDL">
<option value="+" selected="selected">+</option>
<option value="-">-</option>b
<option value="*">*</option>
<option value="/">/</option>
</select>

<input type="text" name="second">
<input type="submit" name="submit" value="Equals">
<input type="text" name="equals" value="<?php if (!empty($equals)) print($equals) ?>">

</form>

</body>
</html>

The previous code results in the following error when accessing the index.php file BEFORE SUBMITTING THE FORM:

a busy cat

The php code "print $_POST[‘DDL’];" is causing the error.

Why is this happening?
I’ve already chosen a default value by using "+"…

  • 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-26T14:32:16+00:00Added an answer on May 26, 2026 at 2:32 pm

    When you first visit the page, you don’t have any post data.
    This fires the exception you’re getting.

    you should check the $_POST value / existence before processing the form data.

    Hope this helps 🙂

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

Sidebar

Related Questions

Take this code: <?php if (isset($_POST['action']) && !empty($_POST['action'])) { $action = $_POST['action']; } if
For example i use this little code: <?php if (isset($_POST['Submit'])){ if ((@$_POST['Submit'] == 'x'))
i have this image upload script. <?php if(isset($_POST['submit'])){ if (isset ($_FILES['new_image'])){ $imagename = $_FILES['new_image']['name'];
I have this code <?php if(isset($_POST['submit'])) { $to = info@bodom.eu; $subject = Form; $name_field
Here's what I am doing, <?php if(isset($_POST['submit'])){ $text_area= mysqli_real_escape_string($dbc, strip_tags(trim($_POST['text_area']))); echo $text_area; } ?>
I can't seem to validate file upload fields, here's my code: <?php if (isset($_POST['submit']))
mailer.php <?php if(isset($_POST['submit'])) { $to = abc@gmail.com; $subject = Contact via website; $name_field =
I have a simple php form, like this: <?php if(isset($_POST['myform'])) // email... else //
i am posting to a mailer.php file. mailer.php <?php if(isset($_POST['submit'])) { $to = testabc@gmail.com;
This works: <input type=text name=foo value=<?php echo isset($_POST['foo']) ? $_POST['foo'] : '' ?>/> This

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.