I want to insert data in the form of a columns

Hello Friends help me plz i am facing some of the doubts in the code here i have made a form to describe the post by the user for example if a user is submitting his or her form he/she will be redirecting to the next page where he/she can see his or her post in the form of a equally divided columns here is the image for what exactly i am trying to insert in my website that if a user fills her detail so another visitors can also be able to see the recent post of each and every people here’s the image plzz help, or give me little bit suggestion so i can start working on it.

Hi @amitkanjiyani3398, you say you have made the form. Could you please post the code that you have so far?

This is the code where the visitor will be describing the concepts related to the topic

<form method="post" action="#">
  <div class="row">
    <div class="input-field col s12">
      <textarea id="txta1" class="materialize-textarea" name="txt_Script" id="word_count" cols="1" rows="1" length="120" ></textarea>
      <label for="txta1">Describe Here</label>max 200characters
                    <div style="position:relative;" class='btn btn-primary'>
		Choose File...<i class="fa fa-file" aria-hidden="true" method="post"></i>
            <input name="userfile"  type="file" id="userfile" type="file" style='position:absolute;z-index:2;top:0;left:0;filter: alpha(opacity=0);-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";opacity:0;background-color:transparent;color:transparent;' name="file_source" size="40"  onchange='$("#upload-file-info").html($(this).val());'>
       <br><span class='label label-info' id="upload-file-info"></span></br>
	$sql="INSERT INTO `describepost`(`post`) VALUE ([$a])";

        echo "Registered";
	echo "Error : ";

Because you have # in the action, the form gets processed in its self.
The header you have in the error section won’t work because it comes after there has been some html output. A header must come before any output.
To make the form redirect you can put another page in the action attribute and do the processing there. Or if you want to use a 'header` redirect, you must put the processing at the beginning of the document, before there is any html output.

There are other issues with the php processing.
You are putting unsanitised user data directly into an sql query which you should never do as it’s a huge security risk. Also you are using the obsolete mysql api, you should be using mysqli or PDO.

1 Like

The thing is not that i have inserted # only for the porpouse of demo only. Let me understand you the whole thing suppose you are the visitor of my site for the first time what you need to do is just fulfill all the requirements for what i am asking for.Say suppose the website is asking for the title and the description about your job then after fulfilling your title and description must be converted in the form of Gigs as like as fiverr. so help me

Then the form processing should record the data to the database, which appears to be what you are trying to do in that code, though not using the best method.
For any redirect to another page to occur you will, like I said, either use a different script to do the processing (via action), or put the processing before the html and use headers.
If you are having the processing and html in the same document, it is probably best to have the processing first anyway.

Along the lines of:-

if ($_SERVER['REQUEST_METHOD'] == 'POST') { // check for submission
  // sanitise data
  // check for errors/validate

  if(...) {  // if everthing is OK
      // connect to database only now

      // prepare a statement to insert the data
      // execute the query

      // if all goes well redirect to wherever 
  else{ // there is a problem
      // do something else
// now the processing is out of the way you can output the html form
<!DOCTYPE html>
      <title>Form Page</title>

Once the data is recorded in the database, it can be recalled by any page you want to display it.

Ohk thats done and was really great but what about the queries related to the gigs?

I only just noticed that the form is for a file upload, that is going to be a bit more involved.
Generally you would not insert the actual file into the database, but save it to a folder somewhere and store a reference to the file name in the database.

So far I know nothing about the structure of your database or the type of data you expect to deal with, such as what type of file you are uploading. So it’s impossible to give any more specific advice.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.