Mysql query, two times?

Posted on 16th Feb 2014 by admin

Hello to all,

I'm new to php coding and i like it alot. I need help with some noob stuff.

1. Having problem with mysql query after submiting HTML form. It's allways execuding two times, that way i have two identical data in table which i do not wont.

HTML code:
Code: [Select]<form name="kluboviForm" method="post" action="kluboviAction.php">
<input name="predsjednik" type="text"/>
<input name="email" type="text"/>
<input name="kontakt" type="text"/>
<input name="sjedisteKluba" type="text"/>
<input name="imeKluba" type="text"/>
<input type="Submit"/>
</form>
PHP code (kluboviAction.php):
Code: [Select]<?php
mysql_connect(localhost,root,'');
mysql_select_db(ljestvica) or die( "Unable to select database");
mysql_query("INSERT INTO klubovi VALUES ('','a','b','c','d','e')");
mysql_close();
?>
After execuding the submit button on form i get this error in google chrome:

Error 101 (net::ERR_CONNECTION_RESET): Unknown error.

But the query is execudet and table is filed with two identical informations.

2. Is there a way to put php function inside action form? I wont to execude php function after someone submits the form. I wont to delete kluboviAction.php file and use function to put the information in to database without the need to use second file. If there is anothere way to do that please let me know.

3. How to redirect URL after execuding submit button to not show message above?

Any help would be appreciated.

Thanks

Other forums