LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Insert Data by FORM in MYSQL (https://www.linuxquestions.org/questions/linux-software-2/insert-data-by-form-in-mysql-73300/)

gruger 07-16-2003 12:50 PM

Problem with inserting Data by FORM in MYSQL
 
Hi all ,

I'm back with another Q.

First going to explain my problem a bit.

I am making a website for a company , nothing fancy , the company just wanted a frameset , standard html page's and some buttons . No problem until they came up wirh another page that needs an update every week :eek:

So I was thinking to do it by PHP and a mysql server.

I do this with a standard form that parses the data to a PHP script and that puts the data in Mysql .

Everything seem to run fine , I am NOT getting an error but .... When I enter data into the form and submit it to the PHP script it says to me
"data insert OK , next please :)" so everything is fine , I think !?!

When I do a look-up into the database no data seems to be inserted , however , there is a new record added to the table ??? I think the data is not getting parsed out of the form into the PHP , so the PHP can't submit the data into the database .

Here is the code from the FORM and from the script .

FORM
---------------
<HTML>
<HEAD><TITLE>INSERT Data via PHP</TITLE></HEAD><BODY>
<FORM action="insert.php" method="get">
<center>
<b>
Promoties :
</b>
<br>
<br>
<input type="text" size="20" name="promo">
<br>
<br>
<br>
<b>
Datum:
</b>
<br>
<br>
<input type="text" name="datum">
<BR>
<br>
<br>
<input type="submit" value="Submit to insert.php">
</center>
</FORM>
</BODY>
</HTML>



PHP SCRIPT
---------------

<HTML>
<HEAD>
<TITLE>INSERT Data via PHP</TITLE>
</HEAD>
<BODY>
<?PHP

#MAKE CONNECTION
$connection=mysql_connect("localhost","root")
or die
('Kan geen verbinding maken met de database server');

#SELECT DATABASE
$db = mysql_select_db('bac', $connection)
or die
("Kan database niet vinden.");

#MYSQL INSERT STATEMENT
$sql = "INSERT INTO
promoties(promo,datum)
VALUES
('$promo','$datum');";

#MYSQL QUERY
$sql_result = mysql_query($sql,$connection)
or die
('Kan data niet inbrengen in de server , contacteer de beheerder');

#PUBLISH OK MESSAGE
echo('Data insert OK , next please :)');

#CLOSE CONNECTION
mysql_close($connection);

?>
</BODY>
</HTML>

If someone can help me with this problem I would really appreciate that ...

Using
distro RH 8.0
kernel 2.4.18-14



And sorry about the typo's :study:


All times are GMT -5. The time now is 03:39 AM.