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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:56:35+00:00 2026-05-23T02:56:35+00:00

Edit 4: The main issue has been resolved – turned out the problem was

  • 0

Edit 4: The main issue has been resolved – turned out the problem was a couple of my typos. (Post, <) Thank you! The data now gets entered into my database ok. I’ll still consider the other tips you are giving me. Very good first experience with stackoverflow.

Edit 1: OK, I forgot to capitalize $_POST. Now I am getting an error “Column count doesn’t match value count at row 1”
Edit 2: I removed ID and added exit();. Now, I have the error message “Column ‘Name’ cannot be null”. I am not sure how/where to add the escape string.
Edit 3: I am following Damien’s instructions, and I have this as my output: “Connected to MySQL
string(8) “TestName” string(16) “Test Description” string(3) “567” string(6) “234567” string(13) “Test@test.com” string(8) “TestPass” Column ‘Name’ cannot be null” – so still the same error.

Original Question:
I am rather new to using MySQL and PHP. I am using MAMP for my server, and have set up a few PHP files, according to instructions I have been given. Right now, the main goal is to be able to set up a user database, and the form in question should create a new user, with username, password, etc.

When I have filled out the form and press submit, it gives the error message for an incomplete form, instead of sending the data like I want it too. (I am not really sure about how sending data to my database works, either.)

Here is the form (I think it’s in HTML):

<form action="create.php" method="post">
 Name:  <input type="text" name="inputName" value="" /><br>
 Description: <input type="text" name="inputDesc" value=""/>
  <br/>
 Phone Number :  (<input type="text" name="inputPArea" value="" />)
- <input type="text" name ="inputPBody" value="" /><br>
 Email: <input type="text" name="inputEmail" value=""/><br>
 Password: <input type="password" name="inputPass" value=""/>

  <input type="submit" name="submit" />

Here is the if/else statement for the error message:

if(!$_Post['submit']){
    echo "please fill out the form";
    header('Location:demo.php');

    }

else {
     mysql_query( "INSERT INTO people (`ID`,`Name`,`Description`,`Area Code`,`Phone Body`,`Email`,`Password`)
               VALUES(NULL<'$name','$desc','$area','$pbody','$email','$pass') ") or die(mysql_error()) ;

echo "User has been added!";
header('Location: demo.php');

     }

Please help! Thank you. It would be nice if you could help me understand how submitting stuff to my database works.

(There is a lot of other PHP stuff, of course. Tell me if you need any of it.)

  • 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-23T02:56:35+00:00Added an answer on May 23, 2026 at 2:56 am
    $name = mysql_real_escape_string($_POST['inputName']);
    $desc = mysql_real_escape_string($_POST['inputDesc']);
    $area = mysql_real_escape_string($_POST['inputPArea']);
    $pbody= mysql_real_escape_string($_POST['inputPBody']);
    $email = mysql_real_escape_string($_POST['inputEmail']);
    $pass = mysql_real_escape_string($_POST['inputPass']);
    

    You access them through the superglobal $_POST array (since you used ‘post’ as the form method), properly sanitized (you should use PDO and prepared statements though, they’ll make your code even safer). ID, if it is set as Auto Increment, is not needed in your query.

    mysql_query( "INSERT INTO people (`Name`,`Description`,`Area Code`,`Phone Body`,`Email`,`Password`) VALUES('$name','$desc','$area','$pbody','$email','$pass') ") or die (mysql_error());
    

    Suggestions:
    Also, consider adding exit(); after your header redirection, to avoid accidental display of the code.

    You should also check if $_POSTs are set if(isset($_POST['postname'])) if you don’t want (or can’t accept) empty values (even if you’re doing a client-side validation for that. Always rely on server-side validation, as client-side can be easily avoided)

    Warning on mysql_real_escape_string:

    A MySQL connection is required before
    using mysql_real_escape_string()
    otherwise an error of level E_WARNING
    is generated, and FALSE is returned.
    If link_identifier isn’t defined, the
    last MySQL connection is used.

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

Sidebar

Related Questions

Backdrop: There are two forms, the main application form and a form to edit
Edit: From another question I provided an answer that has links to a lot
There has been a lot of confusion and a set of corresponding set of
When I start my application I get: The ConnectionString property has not been initialized.
EDIT-Moderator, feel free to delete this question. The problem lay in my background image
Problem: I'd like to specify the main class in a jar file that I
I'm having a funny issue with map_async that i can't figure out. I'm using
I'm trying to edit the output joomla main_menu module so I can make a
Edit: This question was written in 2008, which was like 3 internet ages ago.
EDIT: This was formerly more explicitly titled: - Best solution to stop Kontiki's KHOST.EXE

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.