FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


creating forms using SQL?





leo87
How to create a query form and link it to SQL,such that we should get queries to our ID?
Esch
I'm not sure I understand exactly what you're asking, but there are two steps to getting results back from a form to your database.

1) the HTML for your <form> tag must first specify a PHP script as a target, e.g. <form method="POST" action="<?=$_SERVER["PHP_SELF"]?>"> would specify the script that output the <form> tag as the target of that form. When the form is posted (i.e. the submit button is pressed), your browser sends the data in the form back to the script specified by the action attribute, and PHP parses the result into a number of "superglobals", including $_POST in this case. If you had a named field like the following: <input type="text" name="favorite_color">, you could get at what the user supplied for that field in the target PHP script using $_POST["favorite_color"].

2) Your PHP script must then communicate with your database in order to put the submitted data into a table. Assuming you're using MySQL, you'll want to look up functions like mysql_connect() in order to establish the initial connection, mysql_select_db() to pick a database, and mysql_query() in order to execute SQL commands. The basic idea is that once you've set up the connection, you use mysql_query("insert into tblname (column, names, here) values (data, values, here)"), substituting for the obvious in that example.

Hopefully that'll give you a good idea of where to go. If you need more specific examples of either case, feel free to ask.
Related topics
PHP Toturail
Programming links, info, and tutorials
How To : Secure Your PHP Website
[sql] Get the structure of a table
Form Hit Counter
Hacked by someone sql Injection
Looking to start a CSS based site
Okay, I'm done trying to use CSS for layout.
SQL Tutorial
Advanced MySQL db merging Tutorials
HTML
Trying to restore database
phpBB forum database backup
i need suggestions
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.