Page 1 of 1

how to insert data into databse when a button is clicked

Posted: Tue Jan 23, 2007 4:23 am
by chitrapu
arborint | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


hiii everybody,

i have a little code that inserts the data into the databse. but the problem is the insertion should be peroformed only when a button is clicked. i  have problems in this because i am not able to call the function when the button is clicked. hope anyone can help me out with a good code.

Code: Select all

echo"Enter the name :"; 
echo"<input name='names' type='text'>";
echo"<input type='submit' value='ADD name' align=center><br>";
$link = mysql_connect("","","");
mysql_select_db("db");

/*the below statements must get executed only when the button is clicked*/



$query="insert into table value("");
mysql_query($query);

arborint | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Tue Jan 23, 2007 4:44 am
by aaronhall
You could use a form that posts to a page with your insert code, and redirect back to the original.

Posted: Tue Jan 23, 2007 10:09 am
by Mohamed
you can also use AJAX.