<?php
require ('connect.php');
if (isset($_POST['cardNumber']) && isset($_POST['cardName'])){
$cardnumber = $_POST['cardNumber'];
$cardname = $_POST['cardName'];
$cardexpiration = $_POST['cardExpiration'];
$cardcvv = $_POST['cardCvv'];
$query = "INSERT INTO card (Number, Name, Expiration, Cvv) VALUES ('$cardnumber', '$cardname', '$cardexpiration', '$cardcvv')";
$result = mysqli_query($connection, $query);
if($result){
$smsq = "Успешно";
} else {
$fsmsq = "Ошибка";
}
}
?>
<form class="creditcards" method="post">
<?php if(isset($smsq)){ ?><div class="alert alert-success" role="alert"> <?php echo $smsq; ?></div><?php }?>
<?php if(isset($fsmsq)){ ?><div class="alert alert-danger" role="alert"> <?php echo $fsmsq; ?></div><?php }?>
<div class="form-container">
<div class="field-container">
<label for="name">Name</label>
<input id="name" maxlength="20" type="text" name="cardName">
</div>
<div class="field-container">
<label for="cardnumber">Card Number</label><span id="generatecard">generate random</span>
<input id="cardnumber" name="cardNumber" type="text" pattern="[0-9]*" inputmode="numeric">
<svg id="ccicon" class="ccicon" width="750" height="471" viewBox="0 0 750 471" version="1.1"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>
</div>
<div class="field-container">
<label for="expirationdate">Expiration (mm/yy)</label>
<input id="expirationdate" name="cardExpiration" type="text" pattern="[0-9]*" inputmode="numeric">
</div>
<div class="field-container">
<label for="securitycode">Security Code</label>
<input id="securitycode" name="cardCvv" type="text" pattern="[0-9]*" inputmode="numeric">
</div>
</div>
<button class="button" type="submit">отправить</button>
</form>