Exemple #1
0
 /*** mysql hostname ***/
 $mysql_hostname = DB_HOST;
 //'localhost';
 /*** mysql username ***/
 $mysql_username = DB_USER;
 //'mysql_username';
 /*** mysql password ***/
 $mysql_password = DB_PASSWORD;
 //'mysql_password';
 /*** database name ***/
 $mysql_dbname = DB_DATABASE;
 //'phpro_auth';
 //echo "dbname: " . $mysql_hostname . $mysql_dbname . $mysql_username . $mysql_password;
 $abc = new DatabaseConnect();
 #$abc->executeQuery("select count(*) from phpro_users");
 $abc->executeQuery("select count(*) from addresses");
 try {
     $dbh = new PDO("mysql:host={$mysql_hostname};dbname={$mysql_dbname}", $mysql_username, $mysql_password);
     echo "connected";
     /*** $message = a message saying we have connected ***/
     /*** set the error mode to excptions ***/
     $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     /*** prepare the insert ***/
     $stmt = $dbh->prepare("INSERT INTO phpro_users (phpro_username, phpro_password ) VALUES (:phpro_username, :phpro_password )");
     /*** bind the parameters ***/
     $stmt->bindParam(':phpro_username', $phpro_username, PDO::PARAM_STR);
     $stmt->bindParam(':phpro_password', $phpro_password, PDO::PARAM_STR, 40);
     /*** execute the prepared statement ***/
     $stmt->execute();
     /*** unset the form token session variable ***/
     unset($_SESSION['form_token']);