Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Wygasniecie karty data
Spyder
post
Post #1





Grupa: Zarejestrowani
Postów: 269
Pomógł: 7
Dołączył: 12.10.2006
Skąd: Newcastle Upon Tyne

Ostrzeżenie: (0%)
-----


Witam
Mam taki problem i nie wiem jak go zaczac.

Mam pola imputy w ktore wpisuje date startu karty kredytowej i wygasniecia

Start karty jest

miesiac rok

Wygasniecie

miesiac rok

Mam zrobic porownanie zeby data zalozenia nie byla wieksza od daty wygasniecia

oraz data wygasniecia nie moze byc rowna ani mniejsza niz data aktualna (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif)

Moze ktos wie jak to zaczac (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif)
Go to the top of the page
+Quote Post
Tibod
post
Post #2





Grupa: Zarejestrowani
Postów: 108
Pomógł: 2
Dołączył: 9.05.2007
Skąd: INTERNET

Ostrzeżenie: (0%)
-----


  1. <?php
  2. $data1=explode('/', $data_poczatkowa_karty);
  3. $data2=explode('/', $data_koncowa_karty);
  4.  
  5. $data_start=mktime(0,0,0,0,$data1[0], $data1[1]);
  6. $data_stop=mktime(0,0,0,0,$data2[0], $data2[1]);
  7.  
  8. if ($data_stop<$data_start){
  9. echo "blad";
  10. }
  11. else{
  12. echo 'ok';
  13. }
  14. ?>


Ten post edytował Tibod 31.05.2007, 12:53:28
Go to the top of the page
+Quote Post
Spyder
post
Post #3





Grupa: Zarejestrowani
Postów: 269
Pomógł: 7
Dołączył: 12.10.2006
Skąd: Newcastle Upon Tyne

Ostrzeżenie: (0%)
-----


OK tylko ze mam 2 oddzielne zmienne dla miesiaca i roku.

i dane sa wpisywane dla przykladu

Start
04 ( 1 imput ) 07 (2 imput)

Stop
06 (1 imput) 11(2 imput)

jak z tego zrobic normalny format do porownania co zrobic z dniem ktorego nie ma (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif) z 07 a 2007 sobie poradze
Go to the top of the page
+Quote Post
dr_bonzo
post
Post #4





Grupa: Przyjaciele php.pl
Postów: 5 724
Pomógł: 259
Dołączył: 13.04.2004
Skąd: N/A

Ostrzeżenie: (0%)
-----


Spyder: polacz wartosci tych pol tak zebys uzyskal normalna date a potem porownaj z uzyciem str_to_time()
Go to the top of the page
+Quote Post
Spyder
post
Post #5





Grupa: Zarejestrowani
Postów: 269
Pomógł: 7
Dołączył: 12.10.2006
Skąd: Newcastle Upon Tyne

Ostrzeżenie: (0%)
-----


Ok zrobilem moze komus sie przyda (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)

Plik data.php


  1. <form id="form" name="date" method="post" action="s.php" >
  2.  
  3. Card No<input name="card" type="text" size="30" maxlength="19" ><br><br>
  4. Start &nbsp;&nbsp;
  5. M&nbsp;<input name="smon" type="text" size="1" maxlength="2" >
  6. Y&nbsp;<input name="syear" type="text" size="1" maxlength="2" ><br><br>
  7.  
  8. Expired &nbsp;&nbsp;
  9. M&nbsp;<input name="emon" type="text" size="1" maxlength="2" >
  10. Y&nbsp;<input name="eyear" type="text" size="1" maxlength="2" ><br><br>
  11.  
  12. <input type="submit" name="Submit">


Plik s.php

  1. <?
  2. $smon = $_POST["smon"];
  3. $syear = $_POST["syear"];
  4. $emon = $_POST["emon"];
  5. $eyear = $_POST["eyear"];
  6. $cardno = $_POST["card"];
  7. $nmon = date("m");
  8. $nyear = date("y");
  9.  
  10. $sum = $eyear - $nyear;
  11. $sum1 = $emon - $nmon;
  12. $sum2 = $eyear - $syear;
  13. $check = strlen($cardno);
  14.  
  15. if ( $check < 14 ){
  16. include "date.php";
  17. echo "Minimum Card No 14 digits";
  18. return;
  19. }
  20. if ( $smon == 0 ){
  21. include "date.php";
  22. echo "Wrong Month Format in Star Date";
  23. return;
  24. }
  25. if ( $emon == 0 ){
  26. include "date.php";
  27. echo "Wrong Month Format in Expired Date";
  28. return;
  29. }
  30. if ( $smon > 12 ){
  31. include "date.php";
  32. echo "Wrong Month Format in Star Date";
  33. return;
  34. }
  35. if ( $emon > 12 ){
  36. include "date.php";
  37. echo "Wrong Month Format in Expired Date";
  38. return;
  39. }
  40. if ( $sum < 0 ){
  41. include "date.php";
  42. echo "Card expired";
  43. return;
  44. }
  45. if ( $sum1 < 0 ){
  46. include "date.php";
  47. echo "Card expired";
  48. return;
  49. }
  50. if ( $sum2 <= 0 ){
  51. include "date.php";
  52. echo "Wrong Start Year";
  53. return;
  54. }
  55. else  
  56. {
  57. include "date.php";
  58. echo "Card OK";
  59. }
  60.  
  61. ?>


bardzo prosto ale dziala (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 3.10.2025 - 21:24