I am facing a problem of data inserted twice. Its not the same everytime but exhibits erratic behavior.
User submits a request from a html form to create a new playlist. Code instantiates a new user object and calls a member function to add a new playlist for the user. Code in the member function creates a sql statement and executes it. Problem I am facing is that every other request (random) creates a double entery in the DB(mysql).
Code: php script
....
if($SESSION["USER"]){
$sessionUser = $SESSION["USER"];
$user = new user($sessionUser["ID"]);
if($action == "ADD_NEW_PL"){
$newplname = $_REQUEST["newplname"];
if($newplname != ""){ $user->addNewPlaylist($newplname); }
}
}
Code in the member function:
function addNewPlaylist($plname)
{
$sql = "INSERT INTO PLAYLIST (NAME, USERINFO_ID) VALUES ('$plname', '$this->Id')";
$this->query($sql);
}
the query is excuted at the base object level which is extended by user object.
At the html form level a javascript code submits this form:
<input type="image" src="../../resources/images/go2.gif" align="bottom" border="0" alt="Go" onClick="document.playlist_form.action.value='ADD_NEW_PL'; document.playlist_form.submit();">
Any insight into what is/might be the problem would be appreciated.