Проверка ввода PHP в формах HTML, когда два значения равны друг другу

Я имею в виду что-то вроде этого:

FXMLLoader myLoader = null; Scene myScene = null; Stage prevStage = null;

public void start(Stage primaryStage) throws Exception {
  primaryStage.setTitle("Shop Management");
  myLoader = new FXMLLoader(getClass().getResource("cartHomePage.fxml"));
  Pane myPane = (Pane) myLoader.load();
  CartHomePageUI controller = (CartHomePageUI) myLoader.getController();
  controller.setPrevStage(primaryStage);
  myScene = new Scene(myPane);
  primaryStage.setScene(myScene);
  primaryStage.show();
}

После этого

public void setPrevStage(Stage stage){
    this.prevStage = stage;
}

public void gotoCreateCategory(ActionEvent event) throws IOException {
    Stage stage = new Stage();
    stage.setTitle("Shop Management");
    myLoader = new FXMLLoader(getClass().getResource("createCategory.fxml"));
    Pane myPane = (Pane) myLoader.load();            
    Scene scene = new Scene(myPane);
    stage.setScene(scene);
// prevStage.close(); I don't think you need this, closing it will set preStage to null   put a breakpoint after this to confirm it
    setPrevStage(stage);
    stage.show();       
}

//Method to change scene when menu item create product is on click
@FXML
public void gotoCreateProduct(ActionEvent event) throws IOException {
    Stage stage = new Stage();
    stage.setTitle("Shop Management");
    myLoader = new FXMLLoader(getClass().getResource("creatProduct.fxml"));
    Pane myPane = (Pane) myLoader.load();            
    Scene scene = new Scene(myPane);
    stage.setScene(scene);
// prevStage.close(); I don't think you need this, closing it will set preStage to null put a breakpoint after this to confirm it
    setPrevStage(stage);
    stage.show();      
}

Попробуйте и дайте мне знать, пожалуйста.

0
задан Cormack 6 March 2019 в 15:11
поделиться

1 ответ

использование array_unique () позволяет вам возвращать массив без повторяющихся значений. Затем сравните ваш новый уникальный массив с вашим исходным массивом.

Пример:

if (array_unique($teams) == $teams) {
   // Array is unique
} else {
   header('Location: example.url'); // Bring back to desired page
}
0
ответ дан Kevin 6 March 2019 в 15:11
поделиться
Другие вопросы по тегам:

Похожие вопросы: