2017-05-15 183 views
-1

提交按鈕後,它不會重定向到另一個頁面。有人可以幫助找到這個代碼中的錯誤,以及爲什麼我的按鈕typ1和鱈魚沒有重定向到我已經給出的位置。我的提交按鈕不起作用

<?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"); 
    } 
    ?> 

回答

2

您沒有寫過哪一頁表單提交。

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

你也可以這樣寫你的代碼。我認爲這種方式比你寫的更好。

<?php 
if(isset($_SESSION['sum'])) 
{ 
    $s1=$_SESSION['sum']; 
?> 

<form method="post" action="isWhere">...</form> 

<?php 
} 
?>