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

The Archive Base Latest Questions

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

This is a text book problem in which I’ve followed the exact coding. Yet

  • 0

This is a text book problem in which I’ve followed the exact coding. Yet I keep getting the errors of undefined indices and undefined vairables. I keep going over my code and I think I’m missing the errors from fatigue. Here is the code. Any suggestions. I’m against the clock. Here is the htm file associated with this.

Here are the error message:

 Undefined index: firstname in D:\Inetpub\Ciswebs\CIS54\TYSON_SCHWEIDEL\cReport.php on line 10   PHP Notice: Undefined index: lastname in D:\Inetpub\Ciswebs\CIS54\TYSON_SCHWEIDEL\cReport.php on   line 11 PHP Notice: Undefined index: whenithappened in D:\Inetpub\Ciswebs\CIS54\TYSON_SCHWEIDEL\cReport.php on line 12 PHP Notice: Undefined index: howlong in D:\Inetpub\Ciswebs\CIS54\TYSON_SCHWEIDEL\cReport.php on line 13 PHP Notice: Undefined index: howmany in D:\Inetpub\Ciswebs\CIS54\TYSON_SCHWEIDEL\cReport.php on line 14 PHP Notice: Undefined index: aliendescription in  D:\Inetpub\Ciswebs\CIS54\TYSON_SCHWEIDEL\cReport.php on line 15 PHP Notice: Undefined index: whattheydid in D:\Inetpub\Ciswebs\CIS54\TYSON_SCHWEIDEL\cReport.php on line 16 PHP Notice: Undefined index: fangspotted in D:\Inetpub\Ciswebs\CIS54\TYSON_SCHWEIDEL\cReport.php on line 17 PHP Notice: Undefined index: email in D:\Inetpub\Ciswebs\CIS54\TYSON_SCHWEIDEL\cReport.php on line 18 PHP Notice: Undefined index: other in D:\Inetpub\Ciswebs\CIS54\TYSON_SCHWEIDEL\cReport.php on line 19 PHP Notice: Undefined variable: name in D:\Inetpub\Ciswebs\CIS54\TYSON_SCHWEIDEL\cReport.php on line 33 

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1  /DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 <title>Alien Abduction2</title>
 </head>

 <body>
 <?php
 $first_name = $_POST['firstname'];
 $last_name = $_POST['lastname'];
 $when_it_happened = $_POST['whenithappened'];
 $how_long = $_POST['howlong'];
 $how_many = $_POST['howmany'];
 $alien_description = $_POST['aliendescription'];
 $what_they_did = $_POST['whattheydid'];
 $fang_spotted = $_POST['fangspotted'];
 $email = $_POST['email'];
 $other = $_POST['other'];

 $dbc = mysqli_connect('localhost','cis54student','student','cis54')
 or die('Error connecting to MySQL server');
 $query = "INSERT INTO aliens_abduction (first_name, last_name, when_it_happened, how_long, " .
"how_many, alien_description, what_they_did, fang_spotted, other, email) " .
"VALUES ('$first_name', '$last_name', '$when_it_happened', '$how_long', '$how_many', " .
"'$alien_description', '$what_they_did', '$fang_spotted', '$other', '$email')";

 $result = mysqli_query($dbc, $query)
 or die('Error querying database.' . mysqul_error());

 mysqli_close($dbc);

 echo "Thanks for submitting the form $name<br />";
 echo "You were abducted '  $when_it_happened<br />";
 echo "And were gone for ' . $how_long <br />";
 echo "Number of aliens: ' . $how_many <br />";
 echo "Describe them: ' . $alien_description <br />";
 echo "The aliens did this:  $what_they_did <br />";
 echo "Was Fang there?  $fang_spotted <br />";
 echo "Other comments: ' . $other <br />";
 echo 'Your email address is ' . $email;


?>
</body>
</html>
  • 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-26T20:47:32+00:00Added an answer on May 26, 2026 at 8:47 pm

    I believe you’re getting the notices because when you load the page (when it’s not submitted, i.e. by just clicking here), those variables are not defined. You have two solutions.

    1. Check for the presence of the submit button in $_POST then act accordingly
    2. Change all your variables to test the $_POST array with isset() before using them.

    Solution #1:

    if( isset( $_POST['submit']))
    {
        $first_name = $_POST['firstname'];
        $last_name = $_POST['lastname'];
        $when_it_happened = $_POST['whenithappened'];
        ....
    }
    

    Solution #2:

    $first_name = isset( $_POST['firstname']) ? $_POST['firstname'] : '';
    $last_name = isset( $_POST['lastname']) ? $_POST['lastname'] : '';
    ...
    

    Also, as mario points out, you misspelled mysql_error as mysqul_error.

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

Sidebar

Related Questions

I have the following text tooooooooooooon According to this book I'm reading, when the
I'm typesetting a book with LaTeX. The text design includes pull quotes, which are
I am self-learning C++ from a text book and I have a problem to
I'm trying to build a program to solve a problem in a text book
I have a string which I store book pages. It's something like this: ///0///
I have a page which is displaying the text of a book with pictures
I am using this text editor for my windows forms application This works great
Wikipedia's Wavelet article contains this text: The discrete wavelet transform is also less computationally
I can't seem to get this text to align vertically. Can someone please tell
this is probably pretty simple, but I've got this text file containing a bunch

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.