Seeing that the other answer given has not signaled the use of the MySQL reserved word add
, nor has the OP picked up on the duplicate question, have decided to re-open the question in order to show them, what is happening here.
You see the word "add" here in your query?
$s ="INSERT into cuporder(nama,no_hp,add) ...
^^^
- "ADD/add" is a MySQL "reserved" word and it requires special attention, meaning that you MUST wrap that column in ticks.
I.e.: (and copy/paste exactly as shown. Ticks ` and quotes '
are 2 different animals altogether.
$s ="INSERT into cuporder(nama,no_hp,`add`) ...
The error you left in a comment under the other answer told you where it starts:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'add) VALUES('','','')' at line 1
Notice near 'add)
? There you go; that's where the biggest problem begins.
Or rename that column to something "other" than a reserved word.
Plus, you're open to an SQL injection. Use a prepared statement:
Plus, your POST arrays failed. You need to make sure your form has a POST method and that all elements hold the name attribute for them.
I.e.:
<form method="post" action="your_handler.php">
<input type="text" name="nama">
<input type="text" name="add">
<input type="text" name="no_hp">
<input type="submit" name="Submit">
</form>
Use error reporting.
Add error reporting to the top of your file(s) which will help find errors.
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
// rest of your code
Sidenote: Displaying errors should only be done in staging, and never production.
If you're using your entire code (HTML form/PHP/SQL), then if you're not checking to see if they are "not empty", then that could be another reason why they are empty.
Also consult http://php.net/manual/en/tutorial.forms.php
Footnotes:
Reference for "ADD":
Example pulled from it:
If you want to add to a tableA a column existing in a tableB:
1) Create an empty column in the tableA:
ALTER TABLE tableA ADD color CHAR(20);
2) If you don't have an auto-incrementation in the two tables (tableB for exemple):
ALTER TABLE tableB ADD (id INT AUTO_INCREMENT NOT NULL, PRIMARY KEY(id));
3) Fill the columns with the values:
UPDATE tableA,tableB SET tableA.color=tableB.color WHERE tableA.id=tableB.id;