| | |
HTML Form post to PHP?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Hi, In the HTML forum I asked how I could get the results from a form which I will put on my site via e-mail, I was told:
I was then told to come to this forum and ask about the basics of PHP form processing.
Any help would be appreciated!
Martin
•
•
•
•
Give them a form to fill. The form posts to a PHP, ASP, or ASP.NET program that stores the results in the database. You would have a page you could browse to which retrieves and formats this information - no need for any email at all.
Any help would be appreciated!
Martin
Alright, to process a form to a Database is a pretty simple task, however with no experience it's going to be some work. Below is a link I would suggest taking a look at to get started:
http://www.chauy.com/2005/11/php-mys...ta-into-mysql/
Basically the "jest" of storing form data into a MySQL database as follows:
Create a Database and it's required Tables
Build the Form Section in HTML
Process the Form and store info in MySQL DB
Pull information from database and Display it
If you have any questions, just follow up!
http://www.chauy.com/2005/11/php-mys...ta-into-mysql/
Basically the "jest" of storing form data into a MySQL database as follows:
Create a Database and it's required Tables
Build the Form Section in HTML
Process the Form and store info in MySQL DB
Pull information from database and Display it
If you have any questions, just follow up!
•
•
•
•
Originally Posted by martinkorner
Hi, In the HTML forum I asked how I could get the results from a form which I will put on my site via e-mail, I was told:
I was then told to come to this forum and ask about the basics of PHP form processing.
Any help would be appreciated!
Martin
this is the html form
•
•
•
•
<form action="database.php" method="POST">
firsetname"<br>
<input type="text" name="firstname"><br>
last name:
<input type="text" name="lastname"><br>
<input type="submit" value="submit" name="submit">
</form>
now in this code all this information go to the databse
•
•
•
•
<?
$name=$_POST['firstname'];
$lastname=$_POST['lastname'];
$username="your databse username";
$password="your databse password";
$hostname="localhost";
$db=mysql_connect($hostname, $username, $password) or die ("could not connect to database sorry");
$a=mysql_query("insert into tablename(field1,field2)values('$name','$lastname')");
?>
•
•
•
•
<?
$sel=mysql_query("select * from tablename");
$n1=mysql_num_rows($sel);
$i1=0;
while($i1<$n1)
{
$fname=mysql_result($sel,$i1,"field1");
$lname=mysql_result($sel,$i1, "field2");
print $fname;
print $lname;
$i1++;
}
best of luck
To aarya,
I tried that but I got this error on submitting the form:
I've probably forgotten to chamge something obvious or sommat like that (but I can't see anything wrong
)
Thanks
Martin
I tried that but I got this error on submitting the form:
•
•
•
•
Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /mnt/storage/users/m/a/r/martinkorner/database.php on line 7
could not connect to database sorry
)Thanks
Martin
•
•
•
•
Originally Posted by iammatt
Alright, to process a form to a Database is a pretty simple task, however with no experience it's going to be some work. Below is a link I would suggest taking a look at to get started:
http://www.chauy.com/2005/11/php-mys...ta-into-mysql/
Basically the "jest" of storing form data into a MySQL database as follows:
Create a Database and it's required Tables
Build the Form Section in HTML
Process the Form and store info in MySQL DB
Pull information from database and Display it
If you have any questions, just follow up!
Martin
![]() |
Similar Threads
- Parsing html form. (PHP)
- [urgent] HTML form => XML file (JSP)
- getting user info (PHP)
- question about connecting odbc to sql through php script (PHP)
Other Threads in the PHP Forum
- Previous Thread: Help with jump.php Script
- Next Thread: Adding Compiler Options for PHP in Linux
| Thread Tools | Search this Thread |
apache api array basic beginner binary body broken cakephp class cms code computing confirm cron curl customizableitems database date date/time delete display dynamic echo email error file files filter folder form forms forum function functions gc_maxlifetime global google headmethod href htaccess html iframe image include ip javascript joomla limit link list login malfunction memmory memory menu mlm msqli_multi_query multiple mycodeisbad mysql navigation oop parameter parsing paypal pdf php phpmysql query question random recourse recursion regex script search select seo server sessions snippet source space sql static system table thesishelp trouble tutorial update upload url variable video web webdesign xml youtube





