Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['etape1'])){
- if (empty($_POST['hote_mysql']) || empty($_POST['login_mysql']) || empty($_POST['nom_mysql'])) echo "Veillez rensegnez les champs";
- else{
- $servername = $_POST['hote_mysql'];
- $username = $_POST['username_mysql'];
- $password = $_POST['password_mysql'];
- $dbname = $_POST['nom_mysql'];
- try {
- $conn = new PDO("mysql:host=$servername", $username, $password);
- $conn->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
- $sql = "CREATE DATABASE IF NOT EXISTS $dbname";
- $conn->exec($sql);
- }
- catch(PDOException $e)
- {
- echo " $e->getMessage()";
- }
- $data = ('
- <?php
- try
- {
- $bdd = new PDO("mysql:host='.$servername.';dbname='.$dbname.'", "'.$username.'", "'.$password.'");
- $bdd->exec("SET NAMES utf8");
- }
- catch (Exception $e)
- {
- die($e->getMessage());
- }
- ?>
- ');
- $fp = fopen("inc/connect.php","w+");
- fwrite($fp, $data);
- fclose($fp);
- }
- }
- //DROP DATABASE IF EXISTS test
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement