I have an edit post and create post form, the same form only if it’s to edit, the fields will have the data in the input fields and it will be blank when creating a new post. I want where the input for name to be changed where if there’s blank space to replace with underslash “_”. The form function is as follows :
[php]
// For new post
function newPost() {
$post = new Posts;
$post->storeFormValues( $_POST );
}
// For post edit
function editPost() {
$post->storeFormValues( $_POST );
}
// storeFormValues() function
public function storeFormValues( $params ) {
$this->__construct( $params ); // Store all the parameters
}
// __construct( $params ) function
public function __construct( $data=array() ) {
if ( isset( $data[‘postName’] ) ) $this->postName = preg_replace ( “/[^.,-_’”@?! a-zA-Z0-9()]/", “”, $data[‘postName’] );
}
[/php]
Help on this will be as always greatly appreciated.