<?php
#var_dump($_POST);
$sum = 0;
if($_POST['item1']>0){
	$sum = $_POST['item1'];
}

if($_POST['item2']>0){
	$sum = $sum + $_POST['item2'];
}

if($_POST['item3']>0){
	$sum = $sum + $_POST['item3'];
}

if($_POST['item4']>0){
	$sum = $sum + $_POST['item4'];
}

if($_POST['item5']>0){
	$sum = $sum + $_POST['item5'];
}

$show_sum = number_format($sum);

?>
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
    <!--
    /* セル幅を自動調整 */
    table,
    th,
    td {
        width: auto !important;
    }

    .cp_iptxt {
        position: relative;
        width: 80%;
        margin: 40px 3%;
    }

    .cp_iptxt input[type='text'] {
        font: 15px/24px sans-serif;
        box-sizing: border-box;
        width: 100%;
        letter-spacing: 1px;
        padding-left: 4em;
    }

    .cp_iptxt input[type='text']:focus {
        outline: none;
    }

    .ef {
        padding: 4px 0;
        border: 0;
        border-bottom: 1px solid #1b2538;
        background-color: transparent;
    }

    .ef~.focus_line {
        position: absolute;
        bottom: 0;
        left: 0;
        width: 0;
        height: 2px;
        transition: 0.4s;
        background-color: #da3c41;
    }

    .ef:focus~.focus_line,
    .cp_iptxt.ef~.focus_line {
        width: 100%;
        transition: 0.4s;
    }

    .ef~label {
        position: absolute;
        z-index: -1;
        top: 4px;
        left: 0;
        width: 100%;
        transition: 0.3s;
        letter-spacing: 0.5px;
        color: #aaaaaa;
    }

    .ef:focus~label,
    .cp_iptxt.ef~label {
        font-size: 12px;
        top: -16px;
        transition: 0.3s;
        color: #da3c41;
    }

    .required {
        font-size: 0.8rem;
        color: #da3c41;
    }

    .button {
        background-color: #333;
        color: #fff;
    }

    .button:hover {
        background-color: #59b1eb;
    }

    .button {
        display: inline-block;
        width: 200px;
        height: 54px;
        text-align: center;
        text-decoration: none;
        line-height: 54px;
        outline: none;
    }

    .button::before,
    .button::after {
        position: absolute;
        z-index: -1;
        display: block;
        content: '';
    }

    .button,
    .button::before,
    .button::after {
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
        -webkit-transition: all .3s;
        transition: all .3s;
    }

    @media only screen and (max-width: 800px) {

        .col-head-type1 tr,
        .col-head-type1 th,
        .col-head-type1 td {
            display: block;
            width: auto;
        }

        .col-head-type1 tr:first-child {
            border-top: 1px solid #dbe1e8;
        }

        .col-head-type1 th,
        .col-head-type1 td {
            border-top: none;
        }
    }
    -->
</style>
</head>
<body>
<form name="pay" method="post">
<table>

    <tr>
        <th>お名前<span class="required">必須</span></th>
        <td>
            <div class="cp_iptxt">
                <input class="ef" type="text" name="c_name" placeholder="">
                <label>お名前</label>
                <span class="focus_line"></span>
            </div>
        </td>
    </tr>

    <tr>
        <th>フリガナ</th>
        <td>
            <div class="cp_iptxt">
                <input class="ef" type="text" placeholder="">
                <label>フリガナ</label>
                <span class="focus_line"></span>
            </div>
        </td>
    </tr>

    <tr>
        <th>メールアドレス<span class="required">必須</span></th>
        <td>
            <div class="cp_iptxt">
                <input class="ef" type="text" name="email" placeholder="">
                <label>アドレス</label>
                <span class="focus_line"></span>
            </div>
        </td>
    </tr>

    <tr>
        <th>合計金額</th>
        <td>
        <input type="text" name="sum" style="background-color:#dddddd;font-size: 1.5rem;" value='<?=$show_sum?>' readonly>
        </td>
    </tr>


</table>
<?php
$id = strtotime('now');
?>
<input type="hidden" name="clientip" value="2036776258">
<input type="hidden" name="price" value='<?=$sum?>'>
<input type="hidden" name="sendid" value='<?=$id?>'>
<script>
function payment(){
	
	err_mess = '';
	
	if(document.pay.c_name.value==""){
		err_mess = "名前を入力してください。\n";
	}

	if(document.pay.email.value==""){
		err_mess = err_mess + "メールアドレスを入力してください。";
	}else{
		mail = document.pay.email.value;
		if(mail.match(/^[A-Za-z0-9]{1}[A-Za-z0-9_.-]*@{1}[A-Za-z0-9_.-]{1,}\.[A-Za-z0-9]{1,}$/)){
		
		}else{
			err_mess = err_mess + "メールアドレスの形式が不正確です。";
		}
	}
	
	if(err_mess!=""){
		alert(err_mess);
	}else{
		document.pay.action = "https://sky-visit.com/access";
		document.pay.submit();
	}
}
</script>
<br>
<a class="button" href="javascript:void(0);" onclick="payment();">情報を確定し決済へ進む</a>
</form>
</body>
</html>
