php - How to validate if a variable exist before inserting into table? -


itemprop = "text"> $ projectname is present if I can verify how to validate and prevent it from entering with a pop-up window "This project already exists"? I would like to stop any empty inserts.

Please help!

  $ con = mysqli_connect ("127.0.0.1", "root", "password", "agent"); $ Idq = "SELECT id_project, project name from project, agentsFFO WHERE (agentsInfo.idagency = project.id_agent) and email = '$ _SESSION [email]'" or die (mysql_error ()); $ Result = mysqli_query ($ con, $ idq); $ Row_number = 1; While ($ line = $ result-> fetch_assoc ()) {$ id_agent = $ row ["id_agentid_agent"]; $ Id_project = $ row ["id_project"]; $ Projectname = $ row ["projectname"]; $ Id_project ++; $ ROW_NUMBER ++; } If ($ iss_post ['submit']) {if ($ projectname! = $ _POST ['projectname']) {$ sql = "Enter in project (id_project, projectname, id_agent) value (?,? ,? (Choose honesty from agents email =?)) Key update of duplicates // This is unnecessary, how can I change it? Id_agent` = VALUES (`id_agent`),` projectname` = values ​​(`projectname` ) "; If (($ stmt = $ con- & gt; Ready ($ sql)) === Incorrect) {trigger_error ($ con-> Error, E_USER_ERROR); } $ Result = mysqli_query ($ con, $ idq); $ Row_number = 1; While ($ line = mysqli_fetch_array ($ result)) {$ id_project = $ row ["id_project"]; $ Id_project ++; } (Trigger_error ($ stmt-> error; $ stmt- & gt; bind_param ("sss", $ id_project, $ _POST ["projectname"], $ _SESSION ["email"]) === incorrect) E_USER_ERROR); } If (($ stmt-> executed ()) === incorrect) {trigger_error ($ stmt-> error, E_USER_ERROR); }} And {// duplicate found echo "



  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -