public function row($sql, $params = []) {
$result = $this->query($sql, $params);
return $result->fetchAll(PDO::FETCH_ASSOC);
}
public function create(){
//create query
$query = 'INSERT INTO ' . $this->table . ' SET title = :title, body = :body, author = :author, category_id = :category_id';
//prepare statment
$stmt = $this->conn->prepare($query);
//clean data
$this->title = htmlspecialchars(strip_tags($this->title));
$this->body = htmlspecialchars(strip_tags($this->body));
$this->author = htmlspecialchars(strip_tags($this->author));
$this->category_id = htmlspecialchars(strip_tags($this->category_id));
if(strlen($this->body) === 0) {
return false;
}
//binding of paramters
$stmt->bindParam(':title', $this->title);
$stmt->bindParam(':body', $this->body);
$stmt->bindParam(':author', $this->author);
$stmt->bindParam(':category_id', $this->category_id);
//execute the query
if($stmt->execute()){
return true;
}
//print error if something goes wrong
printf("Error %s. \n", $stmt->error);
return false;
}
{"message":"Post not created."}
body
но и остальные поля? А так же как показать ошибку 403 в случае если не передаётся пост запрос?
так я же написал как, зашифрованные данные можно смело передать в открытом виде, всеравно, даже в случае попадания этих данных в третьи руки никто прочесть что там не сможет.
zGfsoWclWf3oHsVI6DPvQJoxYR0yDYvFxw35jBuIxrfA5RclWA-35
zGfsoWclWf3oHsVI6DPvQJoxYR0yDYvFxw35jBuIxrfA5RclWA-35
а мне нужно что бы это не было видно вообще! implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.google.android.material:material:1.2.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.7.1'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.3.1'
implementation 'com.squareup.okhttp3:okhttp:4.9.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'io.reactivex.rxjava2:rxjava:2.2.8'
implementation 'com.github.bumptech.glide:glide:4.11.0'
implementation 'org.apache.commons:commons-lang3:3.5'
implementation 'commons-io:commons-io:2.4'
implementation 'org.jsoup:jsoup:1.14.3'
implementation 'de.hdodenhof:circleimageview:3.1.0'
implementation 'com.amitshekhar.android:android-networking:1.0.2'