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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:26:26+00:00 2026-05-23T11:26:26+00:00

So I am building a simple question form that allows a user to submit

  • 0

So I am building a simple question form that allows a user to submit a question and once the question is submitted it is sent to the database. I can’t figure out why it isn’t working. Here is my code, first one is the ask.html and the second is the ask.php.

<form action="ask.php" method="POST">
            Name: (not your real name)<br/>
            <input type="text" name="name" id="name"/>
            <br/>
            <br/>
            Question: <br/>
            <textarea name="question" cols="60" rows="10" id="question">
            </textarea>
            <br/>
            <input type="submit" />
        </form>

<?php

include('config.php');
include('open_connection.php');



if ((!$_POST[name]) || (!$_POST[question]))
    {
        header ("Location: ask.html");
        exit;
    }


    //Select database and table
    $db_name = "questionme";
    $table_name = "questions";

    //Insert data into database
    $sql = "INSERT INTO $table_name
    (name, question) VALUES
    ('$_POST[name]', '$_POST[question]')";

    $result = @mysql_query($sql, $connection) or die(mysql_error());

?>

<html>
<head>
<title>Ask</title>
<head>
<body>

<h1>Question Submitted</h1>

<p><strong>Name:</strong>
<?php echo "$_POST[name]"; ?></p>

<p><strong>Question:</strong>
<?php echo "$_POST[question]"; ?></p>

</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-23T11:26:26+00:00Added an answer on May 23, 2026 at 11:26 am

    The following is certainly generating warnings:

    if ((!$_POST[name]) || (!$_POST[question]))
    

    replace with

    if (!isset($_POST[name]) || !isset($_POST[question]))
    

    then absolutely take into consideration what the other dudes answered. On your INSERT:

    ('$_POST[name]', '$_POST[question]')";
    

    would be better off as (they’re also triggering warnings):

    ('{$_POST['name']}', '{$_POST['question']}')";
    

    And on these

    <?php echo "$_POST[name]"; ?></p>
    ...
    <?php echo "$_POST[question]"; ?></p>
    

    have them as

    <?php echo $_POST['name']; ?></p>
    ...
    <?php echo $_POST['question']; ?></p>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a non-developer building a simple Access 2003 database for an NGO that works
Simple question: see title. I'm using .NET 3.5. Elaboration: I'm building a plugin that
I am building a simple Django app that will use scribd to display documents.
I'm building a simple accounting app to be used for personal finance. A user
I just wanted to ask a simple question. I am trying to work out
quick question, I am building a simple trigger which purpose is to decrement the
Quick Express.js question. I've been building a simple rpg charactersheet app over the past
I have a simple question - what is Shadow Building? I've seen it in
I'm building a simple Todo List application where I want to be able to
I'm building a simple ASP.NET web application in VS 2008 with a SQL 2005

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.