Bonjour,
j'ai installé un formulaire mais les variables de sessions s'affiche alétoirement.
voici mon code :
et la page paiement.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127 <?php // define variables and set to empty values $firstname = $lastname = $email = $livre = $format = $amount = ""; /* The $_SERVER["PHP_SELF"] is a super global variable that returns the filename of the currently executing script.*/ if ($_SERVER["REQUEST_METHOD"] == "POST") { $firstname = test_input($_POST["firstname"]); $lastname = test_input($_POST["lastname"]); $livre = test_input($_POST["livre"]); $format = test_input($_POST["format"]); $email = test_input($_POST["email"]); $amount = test_input($_POST["amount"]); } /*The next step is to create a function that will do all the checking for us (which is much more convenient than writing the same code over and over again). We will name the function test_input().*/ function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> <!DOCTYPE html> <html lang="fr"> <head> <title>PhPayPlug</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> <link href="//netdna.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.css" rel="stylesheet"> <script type="text/javascript" src="https://api.payplug.com/js/1.0/payplug.js"></script> <!-- Load jQuery and the validate plugin --> <script src="//code.jquery.com/jquery-1.9.1.js"></script> <script src="//ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script> <!-- jQuery Form Validation code --> </head> <body> <div class="container"> <div class="row"> <div class="tab"> <div role="tabpanel" class="tab-pane col-md-6" id="lightbox"> <form action="payment.php" method="POST" id="create-a-payment" role="form" onsubmit="return checkForm(this);"> <div class="form-group"> <label for="name">Nom:</label> <input type="text" class="form-control" id="lastname" name="lastname" placeholder="Votre nom" required autocomplete="on"> </div> <div class="form-group"> <label for="firstname">Prenom:</label> <input type="text" class="form-control" id="firstname" name="firstname" placeholder="Votre prenom" required autocomplete="on"> </div> <div class="form-group"> <label for="email">Email:</label> <input type="email" class="form-control" id="email" name="email" placeholder="Votre email" required autocomplete="on"> </div> <div class="form-group"> <label>LIVRE :</label> <select id="livre" name="livre" placeholder="Votre livre" placeholder="Votre livre" required autocomplete="on"> <option value="" selected> Choisissez votre livre numérique : </option> <option value="torpeurs">Torpeurs</option> <option value="sahona">Sahona</option> <option value="karma">Karma</option> </select> </div> <div class="form-group"> <label>Format :</label> <select id="format" name="format" placeholder="Votre format" required autocomplete="on"> <option value="" selected>Choisissez votre format :</option> <option value="epub">epub (IPad/IPhone)</option> <option value="pdf">pdf (Version ordinateur)</option> <option value="mobi">mobi (Tablette)</option> </select> <div class="form-group"> <label for="amount">Amount:</label> <input type="hidden" class="form-control" id="amount" name="amount" value="9.90" placeholder="Amount to pay" required autocomplete="on"> </div> <div class="checkbox"> <label> <input type="checkbox" name="check" required autocomplete="off">Je confirme </label> </div> <!--<div class="checkbox"> <label> <input type="checkbox" name="ifttt" id="ifttt" value="yes"> Use Ifttt for notifications </label> </div>--> <button type="submit" id="form" name="form" value="soumis" class="btn btn-primary">Créer une commande</button> </form> <hr /> </div> </div> </div> </div> </body> </html>
et ma page succes qui ne recuperer pas les sessions ou cookie:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63 <?php session_start(); require_once('payplug-php/lib/init.php'); require_once('config.php'); $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $livre = $_POST["livre"]; $format = $_POST["format"]; $email = $_POST['email']; $amount = $_POST['amount']; $customerid = $_POST["livre"]; $shipping = $_POST["format"]; $savecard = $_POST['savecard']; if (isset($savecard)) { $payment = \Payplug\Payment::create(array( 'amount' => $amount*100, 'currency' => 'EUR', 'save_card' => true, 'customer' => array( 'email' => $email, 'first_name' => $firstname, 'last_name' => $lastname ), 'hosted_payment' => array( 'return_url' => 'https://www.joegallandlivre.com/payplug-form1-master/return.php', 'cancel_url' => 'https://www.joegallandlivre.com/payplug-form1-master/cancel.html' ), 'notification_url' => 'https://www.joegallandlivre.com/payplug-form1-master/notifications.html', 'metadata' => array( 'customer_id' => $customerid, 'shipping' => $shipping ) )); } else { $payment = \Payplug\Payment::create(array( 'amount' => $amount*100, 'currency' => 'EUR', 'save_card' => false, 'customer' => array( 'email' => $email, 'first_name' => $firstname, 'last_name' => $lastname ), 'hosted_payment' => array( 'return_url' => 'https://www.joegallandlivre.com/payplug-form1-master/return.php?id', 'cancel_url' => 'https://www.joegallandlivre.com/payplug-form1-master/cancel.html' ), 'notification_url' => 'https://www.joegallandlivre.com/payplug-form1-master/notifications.html', 'metadata' => array( 'customer_id' => $customerid, 'shipping' => $shipping ) )); } $payment_url = $payment->hosted_payment->payment_url; $paymentid = $payment->id; $_SESSION['id']=$paymentid; header('Location:' . $payment_url.'');
la page final est aléroire elle affiche de temps en temps la page.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 <?php session_start(); require_once('payplug-php/lib/init.php'); print_r($_SESSION); ?>
tout mes session_start() sont bien au début.
merci pour votre aide.
Partager