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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:15:44+00:00 2026-05-27T18:15:44+00:00

I have a simple html form and some php that input the POST variables

  • 0

I have a simple html form and some php that input the POST variables into a mysql database. However, I noticed that the form would not input the data when

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

 insert stuff in here
 }

was included. I then removed the if statement above and ran the code. All of the variables were imputed except the ones from the form using POST (ex $_POST[‘var1’]). It seems like the POST variables are not being recognized and I dont know what’s wrong.

ALL CODE:

<?php session_start(); ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>

<script type='text/javascript' src='http://code.jquery.com/jquery-1.7.1.min.js'></script>
<script type='text/javascript' src='http://twitter.github.com/bootstrap/1.4.0/bootstrap-modal.js'></script>
<link rel="stylesheet" href="../css/bootstrap.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../css/basic.css" type="text/css" media="screen" />
</head>
<body>
<?php include '../css/bar.php'; ?>
<div id='content'>
    <?php include '../nav.php'; 
    ?>



    <?php


    if (isset($_POST['submit'])){
    include '../connect.php';
    $question=mysql_real_escape_string($_POST['question']);
    $detail=mysql_real_escape_string($_POST['detail']);
    $date=date("d M Y");
    $time=time();
    $user=$_SESSION['id'];
    $put=mysql_query("INSERT INTO questions VALUES ('','$question','$detail','$date','$time','$user','subject','0')");

    $result=mysql_query("SELECT * FROM questions WHERE user='$user' AND time='$time'");
        while ($row = mysql_fetch_assoc($result)){

             $q=$row['id'];

            }
    }

    ?>

    <form method='POST' action='question.php?q=<?php echo $q ?>'>   
        <p>Question:</p>
        <p><input type='text' name='question' id='question'  maxlength='200'></p>
        <p>Add some detail (optional):</p>
        <p><textarea id='detail' name='detail' ></textarea></p>
        <p>Tags:</p>
        <p><input type='submit' value='submit' name='submit'></p>
    </form>


</div>
<?php include '../footer.php'; ?>
</body>
</html>

TESTPAGE:

<?php 

 include 'connect.php'; 

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

$hhh=mysql_real_escape_string($_POST['hhh']);
$put=mysql_query("INSERT INTO questions VALUES ('','$hhh','','','','','','')");

}



?>

<form action='test.php' method='post'>

<input type='text' name='hhh'>
<input type='submit' name='submit' value='submit'>
</form>
  • 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-27T18:15:45+00:00Added an answer on May 27, 2026 at 6:15 pm

    You have two PHP pages – ask.php and question.php. I (guess)think the ask.php is used to store questions and other details and you want to open a question.php with question id.

    ask.php

    <?php session_start(); ?>
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title></title>
    
    <script type='text/javascript' src='http://code.jquery.com/jquery-1.7.1.min.js'></script>
    <script type='text/javascript' src='http://twitter.github.com/bootstrap/1.4.0/bootstrap-modal.js'></script>
    <link rel="stylesheet" href="../css/bootstrap.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="../css/basic.css" type="text/css" media="screen" />
    </head>
    <body>
    <?php include '../css/bar.php'; ?>
    <div id='content'>
        <?php 
         include '../nav.php'; 
         /*--- If submit button is pressed  ---- */
         if (isset($_POST['submit']))
           {
            include '../connect.php';
            $question=mysql_real_escape_string($_POST['question']);
            $detail=mysql_real_escape_string($_POST['detail']);
            $date=date("d M Y");
            $time=time();
            $user=$_SESSION['id'];
    
            /* SELECT column names you want to use with INSERT statement */
            $put=mysql_query("INSERT INTO questions 
                  (`question`,`detail`,`date`,`time`,`user`,`subject`,`name_of_last_col` ) 
                    VALUES 
                       ('$question','$detail','$date','$time','$user','subject','0')");
            //for debug purpose 
            if($put)
              {
                echo "Record added";
               }
             else
             {
               echo "Can't add record " . mysql_error();
              }
             }
            /*----- End submit block -----------*/
    
           /*----List the questions and select it----------*/
            $time=time(); 
            $user=$_SESSION['id'];
    
            //I think this wont work. Try to remove time comparison from the SELECT statement. 
            $result=mysql_query("SELECT * FROM questions WHERE `user`='$user' AND `time`='$time'");
    
            //$result=mysql_query("SELECT * FROM questions WHERE `user`='$user'");
    
            if($result)
             {
                echo "<table>";
                while($row = mysql_fetch_assoc($result))
                {
                   echo "<tr>";
                   echo "<td>$row[question]</td>";
                   echo "<td><a href='question.php?qid=$row[id]'>Show a question</a></td>";
                   echo "</tr>";
                }
                echo "</table>";
             }
            else
              {
                echo "No questions!!!";
              }
            ?>
    
            <form method='POST' action="ask.php">
                <p>Question:</p>
                <p><input type='text' name='question' id='question'  maxlength='200'></p>
                <p>Add some detail (optional):</p>
                <p><textarea id='detail' name='detail' ></textarea></p>
                <p>Tags:</p>
                <p><input type='submit' value='submit' name='submit'></p>
            </form>
    

    question.php should be:

    <?php
     $qid=$_GET["qid"];
     echo "$qid is selected...";
    ?>
    

    You may split code into two PHP pages – one for save records and another to list and select rows.

    addquestion.php

    <?php 
     session_start(); 
    
     if(isset($_POST['submit']))
      {
       mysql_connect("localhost","user","password") or die(mysql_error());
       mysql_select_db("your_db_name") or die(mysql_error());
    
       $question=mysql_real_escape_string($_POST['question']);
       $detail=mysql_real_escape_string($_POST['detail']);
       $date=date("d M Y");
       $time=time();
       $user=$_SESSION['id'];
    
       $put=mysql_query("INSERT INTO questions 
             (`question`,`detail`,`date`,`time`,`user`,`subject`,`name_of_last_col` ) 
               VALUES 
             ('$question','$detail','$date','$time','$user','subject','0')");
       //for debug purpose 
       if($put)
        {
         echo "Record added";
         }
       else
        {
         echo "Can't add record " . mysql_error();
         }
      }
    ?>
    
    <form method='post' action="addquestion.php">
     <p>Question:</p>
     <p><input type='text' name='question' id='question'  maxlength='200'></p>
     <p>Add some detail (optional):</p>
     <p><textarea id='detail' name='detail' ></textarea></p>
     <p>Tags:</p>
     <p><input type='submit' value='submit' name='submit'></p>
    </form>
    

    questionlist.php

    <?php
      session_start(); 
      $user=$_SESSION['id'];
      mysql_connect("localhost","user","password") or die(mysql_error());
      mysql_select_db("your_db_name") or die(mysql_error());  
      $result=mysql_query("SELECT * FROM questions WHERE `user`='$user'");
    
      if($result)
      {
       echo "<table>";
       while($row = mysql_fetch_assoc($result))
       {
         echo "<tr>";
         echo "<td>$row[question]</td>";
         echo "<td><a href='question.php?qid=$row[id]'>Show a question</a></td>";
         echo "</tr>";
         }
      echo "</table>";
      }
      else
      {
       echo "No questions!!!";
      }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple form with some plain html input like bellow using ASP.NET
There are some HTML based games (ie bootleggers.us) that have a simple login form
I have a simple HTML form that posts to a PHP page, which will
I have this code in my HTML form: <form action=cart.php method=post> <input type=hidden value=1
I have a simple html form. On php page. A simple list is placed
I have a site that has a simple HTML button in a form. All
This is probably a basic html/css question... I have a simple one-button form that
I have a PHP page receiving input from an HTML form via $_POST. The
I have HTML that looks like this: <form id=kinodForm> <input type=text name=element[5] value=krispy kreme
I have a simple MVC form with the following elements: <%= Html.TextBox(FechaInicio) %> Which

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.