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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:11:53+00:00 2026-06-12T05:11:53+00:00

I have a problem posting data in my database with a form. Very basic

  • 0

I have a problem posting data in my database with a form. Very basic stuff I’m sure but Im quite stuck :/

I am able to get stuff out of my database using the select from database routine. So I know that the connection with the databse is probably not the problem.

This is my ‘upload.php’:

<html>
<head>
<title>Upload</title>
</head>
<body>

    <form action="action.php" method="post">

        <fieldset class="first">
             Name: 
        <input type="text" name="author" />
        Heading:
          <input type="text" name="heading" />

        Text:
        <textarea type="text" name="thecontent"> </textarea>
        </fieldset>


        <fieldset>
        <input type="submit"/> 
            </fieldset>
    </form>



</body>
</html>

And this is my ‘action.php’:

<html>
<head>

<title>Send!</title>
</head>

<body>

<?php

 ini_set('display_errors', 1); error_reporting(E_ALL); 

$link = mysql_connect('localhost','name','pasword')
or die ("Unable to connect"); 

$mydb = mysql_select_db('the_database',$link)
or die ("No database found"); 

$author = $_POST['author']; 
$heading = $_POST['heading'];
$thecontent = $_POST['thecontent'];

$mysql_query="INSERT INTO articles ('heading', 'author', 'content')
 VALUES ('$heading','$author','$thecontent')" or die(mysql_error());   

echo "This was send: $author $heading $thecontent <br> ";


 mysql_close()

?> 

</body>
</html>

All help would be much appreciated!!

Cheers,
Ziggy

Thanks for all the help guys! I’m trying to use mysqli to insert the data however it’s not yet working this is my new code in action.php:

<html>
<head>

<title>Send!</title>
</head>

<body>

<?php

 ini_set('display_errors', 1); error_reporting(E_ALL); 
$DB_HOST = 'localhost';
$DB_USER = '**';
$DB_PASS = '***';
$DB_NAME = '***';
@ $db = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME);
if (mysqli_connect_errno()) {
echo 'Error.';
exit();
}

$author = $_POST['author']; 
$heading = $_POST['heading'];
$thecontent = $_POST['thecontent'];

$query = 'INSERT INTO articles ('heading', 'author', 'content')
 VALUES ('$heading','$author','$thecontent')';   

$result = $db->query($query);
    if ($result) {
    echo $db->affected_rows."This was added.";
    } 
    else {
    echo "somethings gone very wrong.";
    }

$db->close();




?> 

</body>
</html>

What am I doing wrong guys?
Help is much appreciated!

Cheers,
Ziggy

  • 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-06-12T05:11:54+00:00Added an answer on June 12, 2026 at 5:11 am
    $mysql_query="INSERT INTO articles    ('heading', 'author', 'content')
     VALUES ('$heading','$author','$thecontent')";
    mysql_query($mysql_query);
    //required to run the query..
    
    And mysql_close(); // missing :p
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem SIMILAR to preventing form data reposting, but not quite the same
I have a problem that is common, but I am not quite sure exactly
I have a problem POSTing data via HTTPS in Java. The server response is
I have a problem in posting the data to server by using httpput methods
I have a problem posting the data from silverlight to the aspx page which
Can anybody help me resolve the problem for posting multipart/form-data using below code. I
I have problem with show or hide form in Window Form Application. I start
I have problem while loading data into html select when users press or click
I have a very strange problem. Using Gmap3, I place the pin on the
I have a problem with some basic ajax and asp.net web service. In my

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.