Jump to content

html forms, php and mysql


tracy

Recommended Posts

I have tried several different methods for inserting data into mysql using php (through an html form).
Unsuccessful...
I can insert the data if I write the data to be inserted into the php code, so I know the mysql connection and php are working.
When I try to have an html form write to insert.php, for example...no go.
Also, when I try to use the self write method...no go.
My server support said that everything is fine there and mentioned something about chmoded...
Any suggestions would be appreciated. 

Link to comment
https://forums.phpfreaks.com/topic/27115-html-forms-php-and-mysql/
Share on other sites

This is the insert.php file.  The html form is simple and writes to this insert.php file, supposedly.  It has two areas to fill in, one that is a make (as in auto make) and one that is model (as in auto model).  That's all...

<html>
<body>

<?php

mysql_connect("localhost","small_user","password");
if (!con)
{
die('could not connect: '.mysql_error());
}

mysql_select_db ('small_whatever');

$sql="INSERT INTO data (Make,Model)
VALUES
('$_POST[make]','$_POST[model]')";

echo "one record added";


?>


</body>
</html>


This is the html form:

<html>
<title>Test Self Form</title>
<body>


<form action="insert.php" method="post">
Make: <input type="text" name="make" />
Model: <input type="text" name="model" />
<input type="submit" />
</form>

</body>
</html>

One more note:

I think it is an issue with the server...permissions or something.

I have written other php codes that write to the mysql and they work fine.  I am mainly interested in knowing more about permissions for file writing on the server, but any help is appreciated.  Thanks.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.