1
How do I make a Dialog appear when the script occurs correctly?
public function addDatabase($name, $collation) {
// Checks whether all fields filled (Prevent future errors)
if (!empty($name) AND !empty($collation)) {
try {
// If you want to change (Don't forget the ;)
// http://dev.mysql.com/doc/refman/5.6/en/create-database.html
$sql_query = 'CREATE DATABASE `'.$name.'` COLLATE `'.$collation.'`;';
// Prepare the query to execute
$query = $this->db->prepare($sql_query);
// Execute the query
$query->execute();
} catch (PDOException $e) {
exit ('DB ERROR: '. $e->getMessage());
}
} else {
if (empty($name)) {
echo '$name está vazio';
}
if (empty($collation)) {
echo '$collation está vazio';
}
}
}
CSS/JS of the dialog: http://materializecss.com/dialogs.html
" PHP that receives the AJAX call " This would be on which page? Inside the form ? EDIT: I’ll try to put it in the controller.php because it takes the model information
– misakie
EDIT: I noticed that it is returning successss and error. However no dialog is appearing in the index. Code completo http://www.codeshare.io/LZKq0
– misakie
You’re not sending anything through ajax, assign a
id
to hisform
and place these lines in your ajax just belowurl: ..
,type: 'POST', data: $('#seuform').serialize()
.– Eduardo Silva
Code updated: More where do I put href and which link? http://www.codeshare.io/LZKq0
– misakie
You will need a php to receive the data from your form and instantiate the class
Controller
, this is the php that needs to be placed in the parameterurl:
of your js code, I’ll make an example here on my machine for you to have a complete view. 4 files will be used (index.php, Controller.php, Model.php and another.php file)– Eduardo Silva
Sorry for the delay, I ran out of computer. But, where is the example?
– misakie