我的提交按钮不起作用

时间:2017-05-15 05:53:27

标签: javascript php html

提交按钮后,它不会重定向到其他页面。有人可以帮助找到此代码中的错误以及为什么我的按钮typ1和cod不会重定向到我已经给出的位置。

<?php
    include("connect.php");
    include("common.php");?>
    <html>
    <head>
    <script>
    function cd()
    {
        document.getElementById('credit').style.display='block';
        document.getElementById('debit').style.display='none';
        document.getElementById('net').style.display='none';
        document.getElementById('cash').style.display='none';
    }
    function db()
    {
        document.getElementById('debit').style.display='block';
        document.getElementById('credit').style.display='none';
        document.getElementById('net').style.display='none';
        document.getElementById('cash').style.display='none';
    }
    function ns()
    {
        document.getElementById('net').style.display='block';
        document.getElementById('debit').style.display='none';
        document.getElementById('credit').style.display='none';
        document.getElementById('cash').style.display='none';
    }
    function cs()
    {
        document.getElementById('cash').style.display='block';
        document.getElementById('debit').style.display='none';
        document.getElementById('credit').style.display='none';
        document.getElementById('net').style.display='none';
    }
    function validate(inputtxt)
    {

        var card1 = /^(?:3[47][0-9]{13})$/;  
      if(inputtxt.value.match(card1))  
            {  
          return true;  
            }  
          else  
            {  
            alert("Not a  credit card number!");  
            return false;  
            }  
        if(card1.length!=16)
        {
            alert("Only 16 digits are allowed");
            return false;
        }


    }
    </script>
    <style>
    .d2
    {
        border: 1px solid black;
        font-size: 30px;
        color: white;
        background-color: #242222;
        padding: 15px 15px 15px 50px;
        font-family: Arial; 
        font-style:;
    }
    .tab{
        width:100%;
        height: 400px;
        padding:25px 10px 10px 25px;
        font-size: 25px;
         padding:15px;
        border:1px solid black;
        border-collapse:collapse;

    }
    #credit
    {
    width: 80%;
    height: 100%;
    padding :25px 15px 15px 15px;
    font-size: 20px;
    }
    #debit{
        width: 80%;
    height: 100%;
    padding :25px 15px 15px 15px;
    font-size: 20px;
    }
    #net{
        width: 80%;
        height: 100%;
        padding :25px 15px 15px 15px;
    font-size: 20px;
    }
    #cash{
        width:600px;
        height:100%;
        padding :25px 15px 15px 15px;
    font-size: 20px;
    float: left;
    }
    .card{
        border: 1px solid black;
    }
    </style>
    </head><body>
    <form method="post">
    <?php
    if(isset($_SESSION['sum']))
    {
       $s1=$_SESSION['sum']; 
    echo "
    <div class='d2'> Make Payment</div>
    <div>
    <table class='tab'><tr><td><button name='cr' style='padding: 14px 20px 14px 20px;font-size:15px;color:white;width:300px;background-color:#373535;cursor:pointer;border-radius:5px;border-color:#363434;border-collapse:collapse;font-weight:inherit;' class= 'c1' onclick='cd()'>Credit Card</button>
    <br/>
    <button name='dr' class='d1' style='padding: 14px 20px 14px 20px;font-size:15px;color:white;width:300px;background-color:#373535;cursor:pointer;border-radius:5px;border-color:#363434;border-collapse:collapse;font-weight:inherit;' onclick='db()'>Debit  Card</button>
    <br/>
    <button name='nb' class='n1' style='padding: 14px 20px 14px 20px;font-size:15px;color:white; width:300px; background-color:#373535;cursor:pointer;border-radius:5px;border-color:#363434;border-collapse:collapse;font-weight:inherit;' onclick='ns()'>Net Banking</button>
    <br/>
    <button name='cash' style='padding: 14px 20px 14px 20px;font-size:15px;color:white;background-color:#373535;width:300px; cursor:pointer;border-radius:5px;border-color:#363434;border-collapse:collapse;font-weight:inherit;'onclick='cs()'>Cash On Delivery</button>
    </td>
    <td ><div id='credit' > <h2>Pay using Credit</h2>
    <hr>
    <label>Card number :</label> &nbsp;&nbsp;&nbsp;<span class='card'><input type='text' name='cardno' placeholder='Card number' required='true'/></span>
    <br/>
    <br/>
    <label>Expiry Date:</label> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type'text' name='month' placeholder='MM' required='true'/>&nbsp;&nbsp;
    <input type'text' name='year' placeholder='YY' required='true'>&nbsp;&nbsp;&nbsp;<input type'text' name='cvv' placeholder='CVV' required='true'/>
    <br/>
    <br/>
    <button type='submit' name='typ1'  style='padding: 14px 35px 14px 35px;font-size:15px;color:white;background-color:#ED0C5B;cursor:pointer;
    border-radius:5px;border-color:#ED0C5B;border-collapse:collapse;font-weight:inherit;'>
    <center>Pay Rs. $s1</center></button>
    <br/>
    <br/>
    <label>This card will be save for faster payment.</label>
    </div>
    <div id='debit' style='display:none' > <h2>Pay using Debit Card</h2>
    <hr>
    <label>Card number :</label> &nbsp;&nbsp;&nbsp;<input type='text' name='cardno'  placeholder='Card number' required='true'/>
    <br/>
    <br/>
    <label>Expiry Date:</label> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type'text' name='mm' placeholder='MM' required='true'>&nbsp;&nbsp;
    <input type'text' name='yy' placeholder='YY' required='true'>&nbsp;&nbsp;&nbsp;<input type'text' name='cvv' placeholder='CVV' required='true'>
    <br/>
    <br/>
    <button type='submit' style='padding: 14px 35px 14px 35px;font-size:15px;color:white;background-color:#ED0C5B;cursor:pointer;border-radius:5px;border-color:#ED0C5B;border-collapse:collapse;font-weight:inherit;'><center>Pay Rs. $s1</center></button>
    <br/>
    <br/>
    <label>This card will be save for faster payment.</label>
    </div>
    <div id='net' style='display:none'> <h2>Pay using Net Banking</h2>
    <hr/>
    <label>Select Bank:</label><input type='radio' value='ICICI'>ICICI &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='radio' value='HDFC'>
    HDFC&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='radio' value='Axis'>Axis
    <br/>
    <br/>
    <label>Account number :</label> &nbsp;&nbsp;&nbsp;<span class='card'>
    <input type='text' name='cardno' placeholder='Enter your Account number' required='true'/>
    </span>
    <br/>
    <br/>
    <button type='submit'  style='padding: 14px 35px 14px 35px;font-size:15px;color:white;background-color:#ED0C5B;cursor:pointer;
    border-radius:5px;border-color:#ED0C5B;border-collapse:collapse;font-weight:inherit;'><center>Pay Rs. $s1</center></button>
    <br/>
    <br/>
    <label>This card will be save for faster payment.</label>
    </div>
    <div id='cash' style='display:none'> <h2>Pay using Cash On Delivery</h2>
    <hr width=100%/>
    <button  name='cod' type='submit' style='padding: 14px 35px 14px 35px;font-size:15px;color:white;background-color:#ED0C5B;cursor:pointer;
    border-radius:5px;border-color:#ED0C5B;border-collapse:collapse;font-weight:inherit;'>
    Place COD Order</button>
    <br/>
    <br/>
    <br/>
    <label>This card will be save for faster payment.</label>
    </div>
    </td>
    </tr>

    </table>
    </div>
    ";


    }
    ?>
    </form></body></html>
    <?php
    if(isset($_POST['typ1']))
    {
        $_SESSION['s2']=$_SESSION['sum'];
        $card=$_POST['cardno'];
        $mon=$_POST['month'];
        $yr=$_POST['year'];
        $cv=$_POST['cvv'];
        $_SESSION['card']=$card;
        $q7="select * from bank where card_no=$card";
       $qry6= mysql_query($q7);
       while($r7=mysql_fetch_array($qry6))
       {
        $m=$r7[3];
        $y=$r7[4];
        $c=$r7[5];
        $money=$r7[6];
        if($mon==$m && $yr==$y && $cv==$c)
        {

                header("location:redirect.php");

        }
        else{
            echo "<script>alert('Your details doesnot match');</script>";
        }
       }

    }
    if(isset($_POST['cod']))
    {
        header("location:cod.php");
    }
    ?>

1 个答案:

答案 0 :(得分:2)

您没有写下提交哪个页面表单。

▶ ./script.sh
Starting process...
Mon May 15 11:43:06 ART 2017
End process. Sleeping 10s
Starting process...
Mon May 15 11:43:16 ART 2017
End process. Sleeping 10s
Starting process...
Mon May 15 11:43:26 ART 2017
End process. Sleeping 10s
Starting process...
Mon May 15 11:43:36 ART 2017
End process. Sleeping 10s
Starting process...
Mon May 15 11:43:46 ART 2017
End process. Sleeping 10s

您也可以像这样编写代码。我认为这种方式比你写的要好。

<form method="post"><!-- action="isWhere" -->