User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,548 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,541 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 2665 | Replies: 5
Reply
Join Date: Aug 2005
Posts: 100
Reputation: martinkorner is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
martinkorner's Avatar
martinkorner martinkorner is offline Offline
Junior Poster

Question HTML Form post to PHP?

  #1  
Apr 21st, 2006
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:
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.

I was then told to come to this forum and ask about the basics of PHP form processing.

Any help would be appreciated!
Martin
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2004
Posts: 191
Reputation: PoA is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 2
PoA PoA is offline Offline
Junior Poster

Re: HTML Form post to PHP?

  #2  
Apr 25th, 2006
Reply With Quote  
Join Date: Apr 2006
Location: Porterville, CA
Posts: 8
Reputation: iammatt is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
iammatt's Avatar
iammatt iammatt is offline Offline
Newbie Poster

Re: HTML Form post to PHP?

  #3  
Apr 26th, 2006
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!
Reply With Quote  
Join Date: Sep 2005
Posts: 139
Reputation: aarya is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
aarya's Avatar
aarya aarya is offline Offline
Junior Poster

Re: HTML Form post to PHP?

  #4  
Apr 28th, 2006
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


see i will give example with simple code

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')");

?>

now to retrive the values u have intered is,(i m giving mysql query for this)
<?
$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++;
}

in these code i have given just logic.i hope it may help you.
best of luck
Reply With Quote  
Join Date: Aug 2005
Posts: 100
Reputation: martinkorner is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
martinkorner's Avatar
martinkorner martinkorner is offline Offline
Junior Poster

Question Re: HTML Form post to PHP?

  #5  
Apr 30th, 2006
To aarya,

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

I've probably forgotten to chamge something obvious or sommat like that (but I can't see anything wrong )

Thanks
Martin
Reply With Quote  
Join Date: Aug 2005
Posts: 100
Reputation: martinkorner is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
martinkorner's Avatar
martinkorner martinkorner is offline Offline
Junior Poster

News Re: HTML Form post to PHP?

  #6  
Apr 30th, 2006
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!

Thanks, I'll try it.
Martin
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 9:01 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC