This question already has an answer here:
- check if row exists with mysql 3 answers
- How do I make a redirect in PHP? 31 answers
This is not a duplicate content, I wouldlike to make PDO Mysql Insertion and avoid any duplicate value ont the "IntervalAPriceList" field. Any associated article is not my desired solution.
I have this Insertion script that work fine but the problem is, the script can duplicate record. The field "IntervalAPriceList" must have a unique value on the table.
My question is: How to redirect user on another page that say "this record "IntervalAPriceList" has already exist" ?
- If "IntervalAPriceList" already exist = redirect to: already_exist.php
- If "IntervalAPriceList" not exist = Make Insertion and redirect to: insertion_success.php
$ps = $pdo->prepare("INSERT INTO pricelist (
IntervalAPriceList,
IntervalBPriceList,
EnvoiVersAbonneePriceList,
EnvoiVersAutrePriceList,
RetraitAboneePriceList) VALUES (?,?,?,?,?)");
$params = array(
$IntervalAPriceList,
$IntervalBPriceList,
$EnvoiVersAbonneePriceList,
$EnvoiVersAutrePriceList,
$RetraitAboneePriceList);
$ps->execute($params);
header("location:../app/admin_grille_tarifaire.php");
</div>