Jump to content

HTML form to database


prcollin

Recommended Posts

Is it easy to create an HTML form that connects to a database through a data handling form. I have php 4.4 on my server and wrote all my scripts in 5.0 language and they dont run so i just wanna use an HTML form to submit to a database and to retrieve info from it.

 

 

Any help would be appreciated

Link to comment
Share on other sites

Im new to this too (so please ignore this if im teaching you how to 'suck eggs'), but i think i can help:

 

I'm working with PHP and MySQL and have

 

<?PHP

mysql_connect("localhost", "username", "password") or die(mysql_error());

mysql_select_db("database name") or die(mysql_error());

echo "<p>Successful connection to database</p>";

 

$strString = "INSERT INTO tablename(`fieldname`, `fieldname`) VALUES (`$value1box`,`$value2box`)";

$result = mysql_query($strString) or die(mysql_error());

 

echo "Results stored in database:";

$strQuery2="SELECT `fieldname1` , `fieldname2` FROM `tablename`";

$result = mysql_query($strQuery2) or die(mysql_error()); 

 

echo "<table border='2'>";

echo "<tr><th>fieldname1</th><th>fieldname2</th></tr>";

while($row = mysql_fetch_array( $result )) {

echo "<tr><td>";

echo $row['fieldname1'];

echo "</td><td>";

echo $row['fieldname2'];

echo "</td></tr>";

}

echo "</table></body></html>";

?>

 

<HTML><BODY>

<form action="<?php $_PHP_SELF ?>" method="POST">

<input type="text" name="value1box" value="ENTER VALUE 1">

<input type="text" name="value2box" value="ENTER VALUE 2">

</form></body></html>

 

 

.... I think :o)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.