PHP - Paypal Integration
Hi Everybody
I am doing online education portal. Teachers and students will be registered on this site. Student will search teachers and create schedule to learn subjects. For that student can pay to the teacher some amount. So that student can increase his/her balance. That means he can transfer some money to website company account through credit card or paypal or google checkout. I did credit card part. But i am not getting any idea to do in paypal. That means student can enter amount and click paypal button, it should show paypal page. So that he can login into his paypal account and pay that amount. After pay that amount we can get IPN (Instant Payment Notification). So that we can store that amount into my database under that student ID. Please tell me how can i do this? Similar Tutorialshi, I'm trying to integrate paypal integration. it is integrated successfully and I've checked on my test account too. i want that as user purchase package he should able to download the file. to do that i want to set return variable. as user complete the payment process on paypal , it should auto come back to my website. as he'll be back I'll set his flag to paid and allow him to download file. the problem I'm facing is on my test account. when i paid money. i didn't return to my website. so i don't know to set his flag to true. any one know its best solution??? i want immediate response to client to pay online. Please advise... Thanks Hi, I just integrate my website with paypal test account. It works fine. now i want that if i pay on paypal website it should return to my website. i use following code to do that <input type="hidden" name="return" value="http://www.miricreation.ae.com/shopping-cart-details.php"> but it didn't working. i also enable auto return url into my test account. but no luck. is there anything need to do for this in code?????????? Please help Thanks Hi, I'm integrated paypal standard integration on my website. It integrated successfully.. we collect the data on website and send all info to paypal. in database order table. I set the status to 0 which means order is pending. Now i'm confused how it'll be 1? when i'll come to know that client has paid the payment. do i need to set it flag manual in admin panel after check into my paypal account? or do i need to send some parameter on return valraible. if he i'll return to that page then query to set flag 1. Please help me on this. and let me know which one is best method??? Looking forward. Best regards Hi, I am integrating Paypal Pro into my checkout and struggling to get it to work correctly.
I am using this code to connect to paypal - which all works correctly, processes payments as it should and send paypal receipts to the customer and to me.
The problem is that when Paypal redirects back to my receipt page, it is not triggering the email (customer_mail_new.php and client_mail_new.php) to tell me what exactly they customer has ordered!
I've been staring at this code for hours now and wonder if anyone can see anything obvious that I have (or haven't) done that is causing the emails to not send at the end of the receipt page?
(paypal.php)
<?php I have a site with a shopping cart that uses a paypal buy now button. The button seems to work fine, when I click it everything in my cart on my site shows up how its suppose to in the paypal checkout page. Then problem is when I try to log into my buyer sandbox account. It's telling me its the wrong email or password when I know for a fact it is correct. I know I need to be logged in to the sandbox developer account while using it, but it still wont let me log in. My site tried to do multiple items using the value _cart for the cmd hidden paypal input and upload. However when I use another example that only does one item at a time and has preset variables my sandbox paypal accoung logs in fine. This makes me think there is something wrong with my code. Here is the code to build my paypal button for my site Code: [Select] $cartOutput = ""; $cartTotal = ""; $pp_checkout_btn = ''; $product_id_array = ''; if (!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1) { $cartOutput = "<h2 align='center'>Your shopping cart is empty</h2>"; } else { // Start PayPal Checkout Button $pp_checkout_btn .= '<form action="https://www.paypal.com/cgi-bin/webscr" method="post" accept-charset="utf-8"> <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="upload" value="1"> <input type="hidden" name="business" value="pwang@sofpower.com">'; // Start the For Each loop $i = 0; foreach ($_SESSION["cart_array"] as $each_item) { $item_id = $each_item['item_id']; $query = "SELECT * FROM product WHERE id='$item_id' LIMIT 1"; $result = $db_obj->query($query); if($db_obj->error) exit ($db_obj->error); //$sql = mysql_query("SELECT * FROM products WHERE id='$item_id' LIMIT 1"); while ($row = $result->fetch_array(MYSQLI_ASSOC)) { $product_name = $row["product_name"]; $price = $row["price"]; $details = $row["details"]; } $pricetotal = $price * $each_item['quantity']; $cartTotal = $pricetotal + $cartTotal; $_SESSION["cart"] = $cartTotal; setlocale(LC_MONETARY, "en_US"); //$pricetotal = money_format("%10.2n", $pricetotal); // Dynamic Checkout Btn Assembly $x = $i + 1; $pp_checkout_btn .= '<input type="hidden" name="item_name_' . $x . '" value="' . $product_name . '"> <input type="hidden" name="amount_'. $x . '" value="' . $price . '"> <input type="hidden" name="quantity_' . $x . '" value="' . $each_item['quantity'] . '"> '; // Create the product array variable $product_id_array .= "$item_id-".$each_item['quantity'].","; // Dynamic table row assembly $cartOutput .= "<tr>"; $cartOutput .= '<td><a href="product.php?id=' . $item_id . '">' . $product_name . '</a><br /><img src="inventory_images/' . $item_id . '.jpg" alt="' . $product_name. '" width="40" height="52" border="1" /></td>'; $cartOutput .= '<td>' . $details . '</td>'; $cartOutput .= '<td>$' . $price . '</td>'; $cartOutput .= '<td><form action="cart.php" method="post"> <input name="quantity" type="text" value="' . $each_item['quantity'] . '" size="1" maxlength="2" /> <input name="adjustBtn' . $item_id . '" type="submit" value="change" /> <input name="item_to_adjust" type="hidden" value="' . $item_id . '" /> </form></td>'; //$cartOutput .= '<td>' . $each_item['quantity'] . '</td>'; $cartOutput .= '<td>' . $pricetotal . '</td>'; $cartOutput .= '<td><form action="cart.php" method="post"><input name="deleteBtn' . $item_id . '" type="submit" value="X" /><input name="index_to_remove" type="hidden" value="' . $i . '" /></form></td>'; $cartOutput .= '</tr>'; $i++; } setlocale(LC_MONETARY, "en_US"); //$cartTotal = money_format("%10.2n", $cartTotal); $cartTotal = "<div style='font-size:18px; margin-top:12px;' align='right'>Cart Total : ".$cartTotal." USD</div>"; // Finish the Paypal Checkout Btn $pp_checkout_btn .= ' <input type="hidden" name="return" value="http://webdev.cs.kent.edu/~jfunchio/wp2/HW2/checkout_complete.php"> <input type="hidden" name="cancel_return" value="http://webdev.cs.kent.edu/~jfunchio/wp2/HW2/paypal_cancel.php"> <input type="image" src="https://www.paypal.com/images/x-click-butcc.gif" name="submit" alt="Make payments with PayPal - its fast, free and secure!"> </form>'; } Here is the example that works Code: [Select] <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <meta charset="utf-8"/> <title>SuperStore.Com</title></head> <body style="margin: 50px"> <h2>Purchase Our Product Online</h2> <p><img src="hammer.jpeg" alt="Hammer" style="vertical-align: middle" /> Hammer for $4.49.</p> <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" accept-charset="utf-8"> <input type="hidden" name="cmd" value="_xclick" /> <input type="hidden" name="business" value="jfunchio@kent.edu" /> <input type="hidden" name="item_name" value="Hammer" /> <input type="hidden" name="amount" value="4.49" /> <input id="tt" type="hidden" name="return" value="success return URL" /> <input id="ff" type="hidden" name="cancel_return" value="failure return URL" /> <!-- company logo for PayPal page --> <input type="hidden" name="image_url" value="http://www.sofpower.com/images/sofppal.gif" /> <input type="hidden" name="cn" value="Special Instructions (optional)" /> <table style="background-color: #ddffee"> <tr><td> </td></tr> <tr><td>Customer Full Name</td><td> <input type="text" name="cnm" size="30" maxlength="50" /></td></tr> <tr><td><input type="hidden" name="on0" value="customer email address" /> Customer email</td> <td><input type="text" name="os0" size="30" maxlength="100" /></td></tr> <tr><td><input type="hidden" name="on1" value="customer institution" /> Customer institution</td> <td><input type="text" name="os1" size="30" maxlength="100" /></td></tr> <tr><td> </td></tr> </table><br /> <input type="image" src="https://www.paypal.com/images/x-click-butcc.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!" /> </form> <p>When payment has been received, we will also send a confirmation to you by email.<br /> After ordering, if you need to get in touch with us, please send email to<br /> <tt>customer-service@superstore.com</tt>.</p> <pre> </pre> </body></html> hey guys. i am not too familiar with how loop works.. or in my case particularly. Here is the situation. i am trying to pass multiple transactions in a single click using paypal's doDirectPayment nvp api. The credit card number, name, address will be the same but the "invoice number" and "amount" will be different for each transaction. The way i have it now is that if there are multiple transactions, it processes them as a whole so if there are four $25 transactions, it charges one amount, $100 and provides one transaction id. I'd like to be able to set those transactions in a loop, so each transaction is billed individually and have its own transaction id returned from Paypal. an example would be this: item_ID-----amount 1 ----- $25 2 ----- $25 3 ----- $25 4 ----- $25 total ------ $100 the code i have currently is this: Code: [Select] <?php /** DoDirectPayment NVP example; last modified 08MAY23. * * Process a credit card payment. */ $environment = 'sandbox'; // or 'beta-sandbox' or 'live' /** * Send HTTP POST Request * * @param string The API method name * @param string The POST Message fields in &name=value pair format * @return array Parsed HTTP Response body */ //function PPHttpPost($methodName_, $nvpStr_) {} $userRes=mysql_query("SELECT * FROM user where id='".$_SESSION['SESS_USERID']."'"); $userRow=mysql_fetch_array($userRes); // Set request-specific fields. $fullname=explode(" ",$userRow['fullname']); $paymentType = urlencode('Sale'); // or 'Authorization' $firstName = urlencode($fullname[0]); $lastName = urlencode($fullname[1]); $creditCardType = urlencode($card_type); $creditCardNumber = urlencode($card_no); // Month must be padded with leading zero $padDateMonth = urlencode(str_pad($exp_month, 2, '0', STR_PAD_LEFT)); $expYr="20".substr($exp_year,-2); $expDateYear = urlencode($expYr); $cvv2Number = urlencode($cvv2); $address1 = urlencode($userRow['address1']); $address2 = urlencode($userRow['address2']); $city = urlencode($userRow['city']); $state = urlencode($userRow['state']); $zip = urlencode($userRow['zip']); $country = urlencode('US'); // US or other valid country code $amount = urlencode($totalamt); $currencyID = urlencode('USD'); // or other currency ('GBP', 'EUR', 'JPY', 'CAD', 'AUD') // Add request-specific fields to the request string. $nvpStr = "&PAYMENTACTION=$paymentType&AMT=$amount&CREDITCARDTYPE=$creditCardType&ACCT=$creditCardNumber". "&EXPDATE=$padDateMonth$expDateYear&CVV2=$cvv2Number&FIRSTNAME=$firstName&LASTNAME=$lastName". "&STREET=$address1&CITY=$city&STATE=$state&ZIP=$zip&COUNTRYCODE=$country&CURRENCYCODE=$currencyID"; // Execute the API operation; see the PPHttpPost function above. $httpParsedResponseAr = PPHttpPost('DoDirectPayment', $nvpStr); if("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) { if($s_list!="") { $updRes=mysql_query("UPDATE cars set s_fee_paid_status='1',seller_paid_date=now() where id in (".$s_list.")"); } if($b_list!="") { $updRes=mysql_query("UPDATE cars set b_fee_paid_status='1',buyer_paid_date=now() where id in (".$b_list.")"); } $exp_date=$exp_month."/".$exp_year; $updRes=mysql_query("UPDATE user set nameoncard='".$nameoncard."',card_type='".$card_type."',card_no='".$card_no."',cvv2='".$cvv2."',exp_date='".$exp_date."' where id='".$_SESSION['SESS_USERID']."'"); //$msgs=urldecode($httpParsedResponseAr["L_LONGMESSAGE0"]); echo "<script> window.location='somewebfile.php?msgs=1'; </script>"; exit; } else { $msgs=urldecode($httpParsedResponseAr["L_LONGMESSAGE0"]); /*echo "<script> window.location='somewebfile.php?msgs=2'; </script>"; exit;*/ } ?> Hello Everyone, I am pretty new to the forums and was curious if i could get some help here. Basically, in a nutshell, i have PayPal integrated into my website. I will use this to collect money from clients. when a client logs into his/her account they see their balance (which is pulled from the database to correspond with the user that's logged-in). Now, everytime a payment is submitted a notify_url is contacted after payment has been verified, that notify_url is the code written below. What I am trying to execute here is when this notify_url is called the current balance is reduced from the amount paid through paypal. In the second If condition, you will see that the word success is being entered into the paypal.txt file, which is working perfectly fine. Now, you will also see the variable $update_balance; which is suppose to update the original balance with the balance paid through PayPal BUT IT'S NOT!! WHY?? LOL Thank You in advance! <?php ob_start(); session_start(); include_once ('/home/rdewebde/public_html/includes/paypal.php'); $myPaypal = new Paypal(); $myPaypal->ipnLog = TRUE; include_once "/home/rdewebde/public_html/includes/_config.php"; $username = "".$_SESSION['username'].""; $users_data = mysql_query("SELECT * FROM `members` WHERE `username`='".$username."'"); $user_info = mysql_fetch_array($users_data); $current_amount = $user_info['balance']; $deduct_amount = $myPaypal->ipnData['payment_gross']; $new_amount = $current_amount - $deduct_amount; $update_balance = mysql_query("UPDATE `members` SET `balance` = '$new_amount' WHERE `username` = '".$username."'"); if ($myPaypal->validateIpn()) { if ($myPaypal->ipnData['payment_status'] == 'Completed') { $update_balance; file_put_contents('/home/rdewebde/public_html/lounge/paypal.txt', 'SUCCESS'); } else { file_put_contents('/home/rdewebde/public_html/lounge/paypal.txt', "FAILURE\n\n" . $myPaypal->ipnData); } } ?> I currently have a project undergoing, however i need help integrating two scripts: Login script & Comment Script The checking if logged in part is this - Code: [Select] if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) { header("location: access-denied.php"); exit(); } and i want it so that i can check if the user is logged in the comment script will use there first name from my mysql table of members. The field name in the table for first name is 'firstname' and my comment section script looks like this Code: [Select] echo "<div class=\"commentbody\" id=\"$commentrow[0]\">\n <p class=\"postedby\">Posted by "; if($commentrow[3]){ echo "<a href=\"$commentrow[3]\">$commentrow[2]</a> "; } else { echo "$commentrow[2] "; } echo "</p> \n <p>$commentbb</p>\n\n</div>"; } echo "</div>"; } Please someone help me, its driving me crazy. Any more info needed just ask many thanks in advance!! Okay, I run a website; I wrote it from scratch, it's own database. With this website, I also run a news section (Run by wordpress), a wiki (Run by MediaWiki), A chat system (X7Chat), and a Live Help system (Mibew Messenger). I am looking to integrate all four of these systems to run off the same login as my main website. I would like it so that when the user logs in to the main site, it automatically logs in and sets the cookies for the other 4 systems. I also want it so when a user registers, it automatically registers them on the other 4 systems. I have achieved this with the chat system. I duplicated the Cookies and I have it so that if a user logs in to the main site, it sets the cookies for the chat, and when a user registers, or changes their password or email, it updates it on the chat table. But, I am finding it quite more difficult for the Wiki, Wordpress, and the Live Help system. The cookies were easy to duplicate for the chat system, and inserting the rows was fairly simple for the chat system, but it is quite a bit more complicated with the other systems. I am hoping someone here has done this before and could help me out on this one, because I am clueless. Thanks in advance for all that help. Okay so i have a flash game website. I want it so that i can list all the games in a category onto one page. So, php selects the items with the category with mysql(for example 'a for arcade' http://url.com/select.php?cat=a) and then lists every game's name and a link to the url (by grabbing the id of the game and providing a link (http://url.com/play.php?id=1) This is the code i have so far.. <?php $con = mysqli_connect('localhost', 'root', 'root', 'games')or die(mysqli_error($con)); if(isset($_GET['cat'])){ $query_var = $_GET['type']; // force it to be an integer $query=" SELECT * FROM games WHERE category = '$query_var'"; $result = mysqli_query($con, $query)or die(mysqli_error($con)); } } ?> <html> <head> <title> Test </title> </head> <body> ? </body> </html> I have set up u chat page on my site and would like to know how to make it use the logged in members user name from my database rather than assigning them a guest name, i think i have found the code that needs editing but i have no idea what needs to be done. I think the editing needs to be done in this code somewhere but i could be wrong, Please help. Code: [Select] <?php require_once dirname(__FILE__)."/src/phpfreechat.class.php"; $params = array(); $params["title"] = "Quick chat"; $params["nick"] = "guest".rand(1,1000); // setup the intitial nickname $params['firstisadmin'] = true; //$params["isadmin"] = true; // makes everybody admin: do not use it on production servers ;) $params["serverid"] = md5(__FILE__); // calculate a unique id for this chat $params["debug"] = false; $chat = new phpFreeChat( $params ); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>phpFreeChat- Sources Index</title> <link rel="stylesheet" title="classic" type="text/css" href="style/generic.css" /> <link rel="stylesheet" title="classic" type="text/css" href="style/header.css" /> <link rel="stylesheet" title="classic" type="text/css" href="style/footer.css" /> <link rel="stylesheet" title="classic" type="text/css" href="style/menu.css" /> <link rel="stylesheet" title="classic" type="text/css" href="style/content.css" /> </head> <body> <div class="header"> <img alt="phpFreeChat" src="style/logo.gif" class="logo2" /> </div> <div class="menu"> <ul> <li class="sub title">General</li> <li> <ul class="sub"> <li class="item"> <a href="demo/">Demos</a> </li> <?php if (file_exists(dirname(__FILE__)."/checkmd5.php")) { ?> <li> <a href="checkmd5.php">Check md5</a> </li> <?php } ?> <!-- <li class="item"> <a href="admin/">Administration</a> </li> --> </ul> </li> <li class="sub title">Documentation</li> <li> <ul> <li class="item"> <a href="http://www.phpfreechat.net/overview">Overview</a> </li> <li class="item"> <a href="http://www.phpfreechat.net/quickstart">Quickstart</a> </li> <li class="item"> <a href="http://www.phpfreechat.net/parameters">Parameters list</a> </li> <li class="item"> <a href="http://www.phpfreechat.net/faq">FAQ</a> </li> <li class="item"> <a href="http://www.phpfreechat.net/advanced-configuration">Advanced configuration</a> </li> <li class="item"> <a href="http://www.phpfreechat.net/customize">Customize</a> </li> </ul> </li> </ul> <p class="partner"> <a href="http://www.phpfreechat.net"><img alt="phpfreechat.net" src="style/logo_88x31.gif" /></a><br/> </p> </div> <div class="content"> <?php $chat->printChat(); ?> <?php if (isset($params["isadmin"]) && $params["isadmin"]) { ?> <p style="color:red;font-weight:bold;">Warning: because of "isadmin" parameter, everybody is admin. Please modify this script before using it on production servers !</p> <?php } ?> </div> <div class="footer"> <span class="partners">phpFreeChat partners:</span> <a href="http://www.jeu-gratuit.net">jeux gratuits</a> | <a href="http://jeux-flash.jeu-gratuit.net">jeux flash</a> | <a href="http://www.pronofun.com">pronofun</a> | <a href="http://areno.jeu-gratuit.net">areno</a> | <a href="http://www.micropolia.com">micropolia</a> | <a href="http://www.zeitoun.net">zeitoun</a> | <a href="http://federation.jeu-gratuit.net">federation</a> </div> </body></html> Hi There, I was wondering if there is a way, or in deed if there is an off the shelf calendar that would be able to interact with an SQL database? I want to be able to display a week's worth of dates (Mon - Fri) - and show what is on each day, for different people, say 4. If possible, I would like it to read start and end dates from the DB, and if that entry is over 3 days, display it on 3 calendar days. Has anyone heard of anything like this, or is it easy to code up? Thanks in advance Matt Hello I have not been able to find my answer anywhere else, so now i post it he Code: [Select] <html> <body> <p></p> </body> </html> <?php $var = 'Some text here!' ?> My questions is now: How do i get the text in the PHP variable into the HTML paragraph text? The code is on the same page Thanks in advance Jones Hey All, I am using a Curl script to call item details from an API and then updating mysql with the results. But the API is limited to 100 requests per 60 seconds. So I am currently just using: $page = $_GET["page"]; $next_page = ++$page; echo "<meta http-equiv='refresh' content='60;url=?page=".$next_page."'>"; This runs until the results from the API runs out, then resets the page number to 1 and loops through again. My question is, will this would the same with a CRON job?
Hello Friends, I am developing a website with frontend as php and backend MySQL. And i am about to integrate the Skipjack payment gateway. But due to lack of sufficient materials and knowledge about this gateway. I am having the problems in integrating this. So all i got is the encrypted FormBuilder html form code which displays a order button only. When it is clicked the form of skipjack loads. But those form fields are already present in the website. So all i need is to pass the form field value plus other values from my website to the skipjack website and to redirect back to my website when the payment is done. Is there any way to do so? Thanks in advance. STRANGESOUL
How to implement the library
here's my code <?php include("../incs/config.php"); $result = mysqli_query($link, "SELECT * FROM press ORDER BY press_date DESC"); $result2 = mysqli_query($link, "SELECT * FROM event ORDER BY event_date DESC"); $result3 = mysqli_query($link, "SELECT * FROM galleries ORDER BY gallery_id DESC"); if (!isset($_COOKIE['user'])) { die("Identifiant invalide"); } ?> <!DOCTYPE html><html> <head><meta charset='UTF-8'> <meta name="robots" content="noindex"> </head> <html> <head> <link rel="stylesheet" href="../css/bootstrap.min.css"> <link rel="stylesheet" href="../css/jquery-ui.css"> <link href="../stylesheets/style.css" rel="stylesheet"> <link href="stylesheets/style.css" rel="stylesheet"> <script src="../js/jquery-migrate.min.js"></script> <script src="../js/jquery.min.js"></script> <script src="../js/jquery.ui.js"></script> <script src="../js/bootstrap.min.js"></script> <script src="../js/tinymce/js/tinymce/tinymce.min.js"></script> </head> <body> <!-- header --> <header> <!-- nav --> <nav class="navbar navbar-default"> <div class="container"> <div class="navbar-header"> <a class="navbar-brand" href="../index.php"><img src="../images/logo.png" alt="Louise Groux"></a> </div><!-- / navbar-header --> <div> <ul class="nav nav-pills navbar-nav" style="font-weight:bold; padding-left:25px;"> <li class="active"><a href="#presse-2" data-toggle="pill"><i class="fa fa-home"></i> Presse </a></li> <li><a href="#evenements-2" data-toggle="pill"><i class="fa fa-comments"></i> Événements </a></li> <li><a href="#galerie-2" data-toggle="pill"><i class="fa fa-cloud"></i> Galerie</a></li> </ul> </div><!--/ nav-collapse --> </div><!-- / container --> </nav> <!-- / nav --> </header> <!-- / header --> <!--<div class="container-fluid"> <div class="row"> <a class="navbar-brand" href="../index.php"><img src="../images/logo.png" alt="logo" width="50" height="50"></a> </div> </div> --> <div class="container content-sm"> <!-- Tab v3 --> <div class="row tab-v3"> <div class="col-sm-9"> <div class="tab-content"> <div class="tab-pane fade in active" id="presse-2"> <div class="container col-md-12""> <h1>Presse</h1> <div style="text-align:center;margin:40px;">Veuillez utiliser la page pour mettre à jour, ajouter et supprimer des articles de presse. Faites glisser pour changer l'ordre et n'oubliez pas de sauvegarder une fois terminé !</div> <ul class="list-unstyled"> <li class="panel panel-info"> <div class="panel-heading"> <h5></h5> </div> <div class="panel-body"> <form action="presse/add.php" method="post" name="form1" enctype="multipart/form-data"> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="title">Tit </label> <div class="col-sm-10"> <input type="text" class="form-control" name='title' id="title" > </div> </div> </div> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="sub_title">Sous-tit </label> <div class="col-sm-10"> <input type="text" class="form-control" name='sub_title' id="sub_title"> </div> </div> </div> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="press_date">Date (invisible, pour l'ordre de la liste):</label> <div class="col-sm-10"> <input type="text" class="form-control datepicker" name='press_date' id="press_date"> </div> </div> </div> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="type">Gen </label> <div class="col-sm-10"> <input type="text" class="form-control" name='type' id="type" > </div> </div> </div> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="type">Lien:</label> <div class="col-sm-10"> <input type="text" class="form-control" name='link' id="link"> </div> </div> </div> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="type">Image (150px x 150px): </label> <div class="col-sm-10"> <input class="input-group" type="file" name="image"/> </div> </div> </div> <input type="submit" name="Submit" class="btn btn-louisegroux pull-right" value="Ajouter"></button> </form> </div> </li> </ul> <?php if ($result->num_rows > 0) { //<button class="save btn btn-louisegroux">Sauvegarder l'ordre des éléments</button> } ?> <div id="accordion-resizer" class="ui-widget-content"> <div id="accordion"> <ul id="draggablePanelList" class="sortable press_sort list-unstyled"> <?php while ($res = mysqli_fetch_array($result)) { $title = $res['title']; $sub_title = $res['sub_title']; $press_date = $res['press_date']; $type = $res['type']; $news_link = $res['link']; $image = $res['image']; $id = $res['id']; $title = stripslashes($title); $sub_title = stripslashes($sub_title); ?> <li name='item' id='item-<?php echo "$id"; ?>' class="panel panel-info""> <div class="panel-heading"> <h3 class="panel-title pull-left"> <?php echo "$title"; ?><span>, </span><?php echo "$sub_title"; ?> </h3> <a href="presse/delete.php?id=<?php echo "$id"; ?>"; ><button class="btn btn-danger clickable pointer pull-right" data-effect="remove"><span class="glyphicon glyphicon-remove"></span></button></a> <div class="clearfix"></div> </div> <div class="panel-body"> <form name="form1" action=presse/edit.php?id="<?php echo "$id"; ?>" method="post" enctype="multipart/form-data"> <div class="col-md-3"> <div class="form-group"> <?php if ($image != "") { ?> <img src="../images/presse/<?php echo "$image"; ?>" class="img-responsive" style="max-height:150px; max-width:150px;"> <?php } ?> <div class="clearfix"></div> <input class="input-group" type="file" name="image"/> </div> </div> <div class="col-md-9"> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="title">Tit </label> <div class="col-sm-10"> <input type="text" class="form-control" name='title' id="title" value="<?php echo "$title"; ?>"> </div> </div> </div> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="title">Sous-tit </label> <div class="col-sm-10"> <input type="text" class="form-control" name='sub_title' id="sTitle" value="<?php echo "$sub_title"; ?>"> </div> </div> </div> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="press_date">Date (invisible, pour l'ordre de la liste):</label> <div class="col-sm-10"> <input type="text" name="press_date" value="<?php echo "$press_date"; ?>"> </div> </div> </div> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="type">Gen </label> <div class="col-sm-10"> <input type="text" class="form-control" name='type' id="type" value="<?php echo "$type"; ?>"> </div> </div> </div> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="type">Lien:</label> <div class="col-sm-10"> <input type="text" class="form-control" name='link' id="link" value="<?php echo "$news_link"; ?>"> </div> </div> </div> </div> <input type="hidden" name="id" value="<?php echo "$id"; ?>"> <input type="hidden" name="old_image" value="<?php echo "$image"; ?>"> <button type="submit" name="update" class="btn btn-louisegroux pull-right">Mettre à jour</button> </form> </div> </li> <?php } ?> Edited October 16, 2019 by samplephp Well this is the code I currently have, it is derived from ajax organic tabs codes. Code: [Select] <? if($filename == "profile"){ ?> <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js'></script> <script src="js/tabs.js"></script> <script> $(function() { $("#profile").organicTabs(); }); </script> <? } ?> It may look fine this way, but rather inflexible if I wish to implement more tabs in future instead of just for the profile page. Assuming I have profile.php, members.php and stats.php and all of the three script files use tab system, the codes will become: Code: [Select] <? if($filename == "profile"){ ?> <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js'></script> <script src="js/tabs.js"></script> <script> $(function() { $("#profile").organicTabs(); }); </script> <? } elseif($filename == "members"){ ?> <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js'></script> <script src="js/tabs.js"></script> <script> $(function() { $("#members").organicTabs(); }); </script> <? } elseif($filename == "stats"){ ?> <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js'></script> <script src="js/tabs.js"></script> <script> $(function() { $("#stats").organicTabs(); }); </script> <? } ?> Which can get even more tedious as more and more pages needs to adopt tabs system. I wonder if there is a way to simplify the code by passing the php variable $filename directly into javascript tabs definition in this line, where the part $("#profile") changes as filename changes? Please help... Code: [Select] $("#profile").organicTabs(); |