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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:57:18+00:00 2026-05-27T19:57:18+00:00

I’m trying to write a page that allows users to type a post and,

  • 0

I’m trying to write a page that allows users to type a post and, when submitted, opens a new page with the post on it. This means that the post must be inputted in a database first before it can be retrieved on another page. This is similar to when someone asks a question on stackoverflow. the question appears on a new page and the page is given a unique id, except i would like this unique id to be in a get variable.

HTML of current page (ask.php):

<form method=POST' action='ask.php?q<php echo $id ?>'>
<input type='text' id='post'>
<input type='submit' value='submit' name='submit'>

PHP:

$post=$_POST['post'];
//then run query to input data into database
}

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

             $id=$row['id'];

            }

ask_action.php:

 <?php header("Location: http://localhost/biology/question.php?q=$id"); ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>


</head>
<body>

<?php
include '../connect.php';
    if (isset($_POST['questionSubmit'])){

    $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','biology','0')");

    $id=mysql_insert_id();

    }
?>


</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-27T19:57:19+00:00Added an answer on May 27, 2026 at 7:57 pm

    If you don’t want the “ask” page to be on the same page that you view the post, you can split this in to three pages.

    Page 1:
    The page with the form where people writes their post and submits. Page 2 will be in the action part of the form.

    Page 2:
    The page that retrieves the POST data. Here you’ll verify all the information and submit it to the database. You then retrieve the insert id and redirect the user to the page where you want to display the results. You use the id from the insert query in the redirecting.

    Page 3:
    Where the users see the submitted information.

    I notice that you’ve tried this approached somehow, but you’ve got a few mistakes that needs correcting. First of all your ask.php page needs improvement.

    You’re missing one apostrophe ( ‘ ) before the POST in method, and your action needs correcting. Remember that the form action is supposed to go to the page that verifies and handles the data from the form. In this case it would be the *ask_action.php* page. Therefore the ask.php page should be like this:

    <form method='POST' action='ask_action.php'>
    <input type='text' name='question' />
    <input type='text' name='detail' />
    <input type='submit'> value='submit' name='submit' />
    </form>
    

    *ask_action.php* will handle the data, verify it and redirect to the page that views it. There is no need for html on the page that verifies it.

    <?php
    include('../connect.php'); // your database connection etc.
    
    if(isset($_POST['submit'])) { // only react if the submit button is pressed
        $question = mysql_real_escape_string($_POST['question']);
        $detail = mysql_real_escape_string($_POST['detail']);
        $date = date("d M Y");
        $time = time();
        $user = $_SESSION['id'];
    
        mysql_query("INSERT INTO questions VALUES('', '$question', '$date', '$time', '$user', 'biology', 0)");
    
        $id = mysql_insert_id();
        header("Location: view_page.php?id=$id");
    } else { 
        echo "Nothing submitted.";
    }
    ?>
    

    Then you’d have a third page where you display the data that you get from the database. If you notice the header function that I’ve used, it’s redirecting the user to view_page.php. This is where you’ll display the data by the id number that is supplied. To get the id number you simply use $id = $_GET['id'];.

    I also noticed that you’re using both time() and date(“d M y”). That is not necessary. If you read about time on php.net you’ll see that the time function generates the current unix timestamp. You can use that to output a date in the way that you want to. For instance: if you’d like to display both the date and time that the question was submitted you can use this date("d M y H:i", $time) where $time is the time-column in your database table.

    This can all be combined in one single page, but I kept them separated so it’s easier for you to see the difference.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,

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.