PHP - Php And Javascript Variable Integration?
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(); Similar TutorialsHello 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. 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? 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?
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 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> hi, 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 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 i have this scroolbar javascript where you implement the text inside the java variable but because i want the data to come from the database i wanted to use a php example <? print($marker); ?> so i was wondring if it is possible to add a php variable into a javascript like this my javascript at moment the javascript variable is like this Code: [Select] var myMainMessage=" Try this out! The message just keeps repeating. Use it for announcements, news and other items! ";i want to change to this Code: [Select] var myMainMessage="<? print($marker); ?>";is it possible if so can someone show me an example thanks the whole javascript Code: [Select] <SCRIPT LANGUAGE="JavaScript"> <!-- This script and many more are available free online at --> <!-- The JavaScript Source!! http://javascript.internet.com --> <!-- (c) http://www.wyka-warzecha.com --> <!-- Begin // THESE VARIABLES where i want to add the php // var myMainMessage=" Try this out! The message just keeps repeating. Use it for announcements, news and other items! "; var speed=150; var scrollingRegion=50; // END CHANGEABLE VARIABLES // var startPosition=0; function mainTextScroller() { var mainMessage=myMainMessage; var tempLoc=(scrollingRegion*3/mainMessage.length)+1; if (tempLoc<1) {tempLoc=1} var counter; for(counter=0;counter<=tempLoc;counter++) mainMessage+=mainMessage; document.mainForm.mainTextScroller.value=mainMessage.substring(startPosition,startPosition+scrollingRegion); startPosition++; if(startPosition>scrollingRegion) startPosition=0; setTimeout("mainTextScroller()",speed); } // End --> </script> hi, I'm integrating google checkout on my website using php. anyone have any idea if google checkout take payment on website just like paypal payment pro??? Looking forward. Best regards 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 i get Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\AtomicPool\s.php on line 93 Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\AtomicPool\s.php on line 95 when i use this code: <?php $dbhost = 'xxxx'; $dbname = 'xxxx'; $dbuser = 'xxx'; $dbpass = 'xxxxxx'; $connect = mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error()); mysql_select_db($dbname) or die(mysql_error()); if (isset($_GET['cat'])){ $cat = $_GET['cat']; $get_cat = mysql_query("SELECT * FROM categories WHERE Short Name = '$cat'"); $get_cat_rows = mysql_num_rows($get_cat); --This is Row 93 if ($get_cat_rows=1){ while ($fetch = mysql_fetch_assoc($get_cat)){ --This is Row 95 $categoryyyy = $fetch['Name']; $categ = "".$categoryyyy." Games"; } } } else echo "Looks like someone has been playing with the URL bar..."; ?> Hi
I am working as a PHP developer in my organization. They asked me to integrate several couriers in of our client's website. As i have only 1 year of experience and i am new to this.
Can any one help me by sending me the courier integration scripts in PHP for
1. Blue Dart
2. Delhivery
3. FEDEX
4. ARAMEX
5. GATI
Kindly help me.
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 I'm having some trouble getting some kind of validation built into a form on my site. I'm using multiple scripts in a form including a lightwindow, as well as some other scripting I found to allow me to submit my form inside the lightwindow. I'm dying to get some kind of validation code added to the script to stop all of the spam emails, but I'm not able to do it, as I don't truly know PHP. I tried using a recaptcha, following the instructions carefully, but I think my problem there was that I don't have a simple Code: [Select] <input type="submit" /> instead, I have: Code: [Select] <a href="thanks.php" style="text-decoration: none" params="lightwindow_form=Catering,lightwindow_width=632,lightwindow_height=1600" class="lightwindow_action" rel="submitForm"><button tabindex="21">Submit</button></a> Could anyone take a look and give me some pointers? mikeandzachsbbq DOT com/Catering/ - click on the link that says Click Here to use our Do-It Yourself mikeandzachsbbq DOT com/Catering/form.php - form w/out the lightwindow Thanks in advance |