Jump to content

[solved] Module prestashop, how to post mysql query?


Recommended Posts

hi,

 

/* $html .= '
 <h2>'.$this->displayName.'</h2>
 <form action="'.Tools::htmlentitiesutf8($_SERVER['REQUEST_URI']).'" method="post">
  <fieldset>
<p><label for="num_id">'.$this->l('Indique o seu ID').' :</label><input type="text" id="num_id" name="ID"/>
 
<input " type="submit" name="submitModule" value="'.$this->l('Update settings').'" class="button" /></center></p>

  </fieldset>
 </form>
 ';

 

With that form how can i sent the id_num to prestashop database? My module already create the table during the install.

 

this code is for back-office of prestashop

Edited by vekia (see edit history)
Link to comment
Share on other sites

if ($_POST['submitModule'])
{
Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'ID` (app_id) VALUES
("$_POST[id]")');
}

 

thats works :), but is not register the ID, it register the "$_POST[id]", could be because i use the "" or ' ' on the wrong way

Edited by sacl02 (see edit history)
Link to comment
Share on other sites

I will try that later, now i have another problem to fix.

 

echo "<script>";
echo "var app_appid = 'e8ad9b1';";
echo "</script>";
echo "<script src='' type='text/javascript' language='JavaScript'></script>";

 

this is a javascript code in php file. How can i get the 'e8ad9b1' from database prestashop?

 

echo "var app_appid = 'e8ad9b1';";

example

echo "var app_appid = '$_POST[iD]';";

Link to comment
Share on other sites

When i install the module create a table in prestashop .

 

the code:

public function installDB()
 {

  DB::getInstance()->Execute('
  CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'ID_test` (
 `num_id` int(10) unsigned NOT NULL auto_increment,
 `app_id` varchar(255) NOT NULL,
 PRIMARY KEY (`num_id`))
 ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8 ;');


  return true;

 } 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...