RSS Forums RSS
Please support our PHP advertiser: Lunarpages PHP Web Hosting

HTML Form post to PHP?

Join Date: Sep 2005
Posts: 139
Reputation: aarya is an unknown quantity at this point 
Rep Power: 4
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  
All times are GMT -4. The time now is 12:05 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC