Jump to content

Lucky2710

Members
  • Posts

    119
  • Joined

  • Last visited

    Never

Everything posted by Lucky2710

  1. I figured it out i ditched my first idea when i figured out people were doing this on a link with auto-redirect. Step 1: Initialize the javascript sdk Step 2: Put a link to logout Code for link -------------------- <a href="#" onclick="javascript:FB.logout(function() { window.location='PUT YOUR REDIRECT URL HERE' }); return false;">Logout</a> NOTE: I am running the facebook login as a parrallel login to my websites current php login system so my redirect url went to a page that runs (almost in the background) to destroy my php session and then again auto redirects back to my index page. By doing it this way in the users ONE click it logs them completely out of both facebook and my website Code for my redirect (aka. my website log out) -------------------------------------------------------------- <?php include_once('framework/checkuserlog.php'); ?> <script> function killSession(){ var code = "<?php session_destroy();?>"; return (code); } killSession(); </script> <script> location.href='index.php'; </script>
  2. I'm using facebook connect as an alternative login method for my users on my website. (ex forget your credentials to my website use your facebook credentials) Ive got the facebook login working and ive got it working in conjunction with my login system. In facebooks terms and conditions you have to include a facebook logoff if you have a facebook login on your website. I have managed to get it to logoff on a <button></button> But thats the oinly way i can get it to work! I need it to run automatically on my logout script page. My current Logout.php (NOTE: Only kills the session and logs out of my php login script THE JAVASCRIPT DOES NOT WORK CORRECTLY AND LOGOUT OF FACEBOOK LIKE ITS SUPPOSED TO) <?php include_once('framework/checkuserlog.php'); ?> <div id="fb-root"></div> <script> window.fbAsyncInit = function() { FB.init({appId: 'APP_ID_HERE', status: true, cookie: true, xfbml: true}); FB.logout(function(response) {}); }; (function() { var e = document.createElement('script'); e.async = true; e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; document.getElementById('fb-root').appendChild(e); }()); </script> <?php session_destroy(); ?> <script> location.href='index.php'; </script> Working Script To Logout on a <button> <div id="fb-root"></div> <script type="text/javascript"> var button; var userInfo; window.fbAsyncInit = function() { FB.init({ appId: 'APP_ID_HERE', status: true, cookie: true, xfbml: true, oauth: true}); showLoader(true); function updateButton(response) { button = document.getElementById('fb-auth'); userInfo = document.getElementById('user-info'); if (response.authResponse) { //user is already logged in and connected FB.api('/me', function(info) { login(response, info); }); button.onclick = function() { FB.logout(function(response) { logout(response); }); }; } else { //user is not connected to your app or logged out button.innerHTML = 'Login with Facebook'; button.onclick = function() { showLoader(true); FB.login(function(response) { if (response.authResponse) { FB.api('/me', function(info) { login(response, info); }); } else { //user cancelled login or did not grant authorization showLoader(false); } }, {scope:'email,user_birthday'}); } } } // run once with current status and whenever the status changes FB.getLoginStatus(updateButton); FB.Event.subscribe('auth.statusChange', updateButton); }; (function() { var e = document.createElement('script'); e.async = true; e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; document.getElementById('fb-root').appendChild(e); }()); function login(response, info){ if (response.authResponse) { var accessToken = response.authResponse.accessToken; userid = response.authResponse.userID; userInfo.innerHTML = ''; button.innerHTML = 'Logout'; showLoader(false); document.getElementById('other').style.display = "block"; } } function logout(response){ userInfo.innerHTML = ""; document.getElementById('debug').innerHTML = ""; document.getElementById('other').style.display = "none"; showLoader(false); } function showLoader(status){ if (status) document.getElementById('loader').style.display = 'block'; else document.getElementById('loader').style.display = 'none'; } </script> <button id="fb-auth">Login with Facebook</button> <div id="loader" style="display:none"></div> <div id="user-info"></div> <div id="debug"></div> <div id="other" style="display:none"></div> Stuff that might help with a solution ------------------------------------------------ All Facebook connect code is using facebooks javascript sdk loaded Asynchronously All my traditional custom built login script is built in php and is almost 100% mysql database driven Server:Apache/2.0.52 (Red Hat) MySQL Server: Version 5.1.42
  3. I've done this before I just can't remember how will someone point me in the right direction? Thanks Say you have this url http://myurl.com/page.php?code=AQBpGFUngD How can i pull the ''code" variable from the url back into a php variable that i can use it again on my page? Thanks ahead of time!
  4. I'm not sure if this question is better asked here or in the 'other' category in client side but that category of forums has less traffic so i'm posting here. I am trying to mix php, mysql, and flash all togather. In mysql ive got a table with information regarding my photo gallery (columns are like 'id' 'location' 'date' 'uploader' ect) I am using php to pick 5 random pictures and return those 5 picture locations into 5 different php variables. NOW MY ISSUE: How can I send those 5 php variables into flash (as3) as 5 as3 variables??? Any help would be appreciated!
  5. Thanks for the help i got it now
  6. Im working on a site and particularly the photo gallery section. I want to display 9 images on 3 rows (3 per row). And im stuck. Te only way i can get the images to show up not one on top of the other is by using a table. but how can i tell the table to only put 3 <td>'s then to <br> Heres my code so far... <?php $sql_images = mysql_query("SELECT * FROM photos ORDER BY upload_date DESC LIMIT 9"); while($row = mysql_fetch_array($sql_images)){ $photo_id = $row["id"]; $location = $row["location"]; $display_pics .= ' <td width="125px"> <a href="image.php?id='. $album_id .'" class="black"><img src="images/uploads/thumbs/' . $location . '" /></a> </td>'; } ?> Then to display it ... <table width="top" cellpadding="10" cellspacing="20"> <tr> <?php echo $display_pics; ?> </tr> </table> My goal is to do it as simple as possible! Can anyone help? If you don't think tables are the way to go im open to any suggestions. I've thought about <divs> but then the images show up one on top of the other and not beside each other. By the way all the images are a max of 100px heigh and 100px wide Thanks for any help or suggestions!
  7. I currently have a login script in place on my site and to get to certain pages you have to be logged in to get to. So when a user tries to go to one of those pages and is not logged in it sends them to the login page (which is great) But on the login page once they login it uses " header('Location: index.php') " to automatically send them to the index page logged in. How can i dynamically see what page they are coming from that way when they login I can send them back to where they where trying to get to to begin with. (like if they click on "Profile" and they are not logged in it sends them to "login" then they login and it currently sends them to "index" I want it to dynamically know to send them back to "profile" instead) If this doesn't make sense and i will try and explain it better But if you understand and know how to do this please help Thanks ahead of time!
  8. I have an upload system on my web site. On the server side of things it only accepts certain file types .gif, .jpg, .png, and .jpeg. How can I make it so that when they are browsing for files with the form <input type="file" name="file" /> that they can only select those same file types. I don't want people to be able to even try and upload anything besides my specified image types!
  9. Or is there a way to write a code that will automatically shrink it to fit inside 80px x 80px without making it look stupid by stretching it outa wack??
  10. Great I got it working almost perfectly! Thanks ONE LAST Question! How can I put a restriction for max height and max width. I need the file to be no larger than 80px x 80px How do I go about doing that? Heres my current WORKING code... (I just need some help with restrictions) <?php if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) || ($_FILES["file"]["type"] == "image/png") && ($_FILES["file"]["size"] < 200000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("images/avatars/uploads/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "images/avatars/uploads/" . $_FILES["file"]["name"]); echo "Stored in: " . "images/avatars/uploads/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } ?>
  11. On my website I currently have it set up so that each user can pick there "avatar" (little picture or icon) Each user has the same choices but they all can pick different ones. I want to make it where they can upload their own picture and have a custom avatar. Where Should I start?
  12. I am trying to incorporate a spry accordion into my site. I have the accordion exactly how i want it except, I don't want the first panel to be open when the page loads. I want the user to have to click which panel to open. Everything i've read online says this is in javascript but everything that i read has been wrong so far! Cause I'm still stuck!!! Thanks
  13. Thanks AbraCadaver Thats way shorter and does the same thing.
  14. Because it was quicker to create to begin with, and made the code way shorter, because instead of on the picks page having to specify each team for each game, all i had to do was say 1 = away and 2 = home. At the time it seemed like the best way to go. And now trying to make it user friendly to show them what they picked. Now its gonna be just as complicated, and long. But i'm not re doing all the stuff i've done so far. So im just gonna keep going with how it is. This thread, i had a code error. Problem solved! my if statements i forgot the { & }.
  15. I have an assoc array thats pulled from mysql. Heres the array... Array ( [0] => Array ( [iD] => 288 [user_ID] => 61 [Game_ID] => 12 [Week] => 1 [Pick] => 1 ) [1] => Array ( [iD] => 287 [user_ID] => 61 [Game_ID] => 11 [Week] => 1 [Pick] => 2 ) [2] => Array ( [iD] => 286 [user_ID] => 61 [Game_ID] => 10 [Week] => 1 [Pick] => 2 ) [3] => Array ( [iD] => 285 [user_ID] => 61 [Game_ID] => 9 [Week] => 1 [Pick] => 2 ) [4] => Array ( [iD] => 284 [user_ID] => 61 [Game_ID] => 8 [Week] => 1 [Pick] => 1 ) [5] => Array ( [iD] => 283 [user_ID] => 61 [Game_ID] => 7 [Week] => 1 [Pick] => 1 ) [6] => Array ( [iD] => 282 [user_ID] => 61 [Game_ID] => 6 [Week] => 1 [Pick] => 2 ) [7] => Array ( [iD] => 281 [user_ID] => 61 [Game_ID] => 5 [Week] => 1 [Pick] => 1 ) [8] => Array ( [iD] => 280 [user_ID] => 61 [Game_ID] => 4 [Week] => 1 [Pick] => 2 ) [9] => Array ( [iD] => 279 [user_ID] => 61 [Game_ID] => 3 [Week] => 1 [Pick] => 2 ) [10] => Array ( [iD] => 278 [user_ID] => 61 [Game_ID] => 2 [Week] => 1 [Pick] => 1 ) [11] => Array ( [iD] => 277 [user_ID] => 61 [Game_ID] => 1 [Week] => 1 [Pick] => 2 ) ) I need to search the arrays inside the main array, to look for where "Pick = 1" if so then echo Away, and some info out of that array. Or if "Pick = 2" then echo Home and some info from that array. And i need it to do foreach array inside that array. I need to search this array. Heres my code so far... $user = 61; $query = " SELECT * FROM CollegeFootballPicks WHERE CollegeFootballPicks.User_ID = $user"; $result = mysql_query($query); $affected = mysql_num_rows($result); echo $affected; echo '<br />'; for($i=0; $i<$affected; $i++){ $picks[] = mysql_fetch_assoc($result); } foreach($picks as $pic) if($pic['Pick'] == 1) echo $pic['User_ID'];echo '<br />'; echo $pic['Game_ID'];echo '<br />'; echo $pic['Week'];echo '<br />'; echo 'Away';echo '<br />';echo '<br />'; foreach($picks as $pic) if($pic['Pick'] == 2) echo $pic['User_ID'];echo '<br />'; echo $pic['Game_ID'];echo '<br />'; echo $pic['Week'];echo '<br />'; echo 'Home';echo '<br />';echo '<br />'; But this isn't working. But i have no errors. Does anyone know how i can search the nested array.
  16. Lucky2710

    help

    Heres wat i got... <?php ini_set('display_errors',1); error_reporting(E_ALL); include '../myconfiginfo/datab.php'; ?> <? $result = mysql_query("SELECT * FROM NascarPicks WHERE User_ID='61'"); $affected = mysql_num_rows($result); $i=0; while($i<$affected) { $i++; $pick = mysql_fetch_assoc($result); ?> <table width="100%" border="0" cellspacing="3" cellpadding="0"> <tr> <td colspan="2">CARFAX 400 at Michigan - Michigan International Speedway</td> </tr> <tr> <td width="8%">1st</td> <td width="92%"> <? if(in_array('81510', $pick)){ echo $pick['p1']; } ?> </td> </tr> <tr> <td>2nd</td> <td> <? if(in_array('81510', $pick)){ echo $pick['p2']; } ?> </td> </tr> <tr> <td>3rd</td> <td> <? if(in_array('81510', $pick)){ echo $pick['p3']; } ?> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td colspan="2">NASCAR Sprint Cup Series at Bristol Bristol Motor Speedway</td> </tr> <tr> <td>1st</td> <td> <? if(in_array('82110', $pick)){ echo $pick['p1']; } ?> </td> </tr> <tr> <td>2nd</td> <td> <? if(in_array('82110', $pick)){ echo $pick['p2']; } ?> </td> </tr> <tr> <td>3rd</td> <td> <? if(in_array('82110', $pick)){ echo $pick['p3']; } ?> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td colspan="2">NASCAR Sprint Cup Series at Atlanta Atlanta Motor Speedway</td> </tr> <tr> <td>1st</td> <td> <? if(in_array('90510', $pick)){ echo $pick['p1']; } ?> </td> </tr> <tr> <td>2nd</td> <td> <? if(in_array('90510', $pick)){ echo $pick['p2']; } ?> </td> </tr> <tr> <td>3rd</td> <td> <? if(in_array('90510', $pick)){ echo $pick['p3']; } ?> </td> </tr> <tr> <td> </td> <td> </td> </tr> </table> <table width="100%" border="0" cellpadding="0" cellspacing="3"> <tr> <td colspan="2">NASCAR Sprint Cup Series at Richmond Richmond International Raceway</td> </tr> <tr> <td>1st</td> <td> </td> </tr> <tr> <td>2nd</td> <td> </td> </tr> <tr> <td>3rd</td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> </table> <? } ?> Goal of the script is to show users current an previous picks. All the data is stored in NascarPicks table. Table has fields id, User_ID, Race, p1,p2,p3. Race is the trace date. (i.e 81510 for August 15, 2010) With the current script it pulls all the info but it shows the< table> once for each piece of info pulled and then it displays all the info from the mysql table but only 1 per time that the <table> shows up. How do i make the table only show up once and all my info display properly. (the order of the info will not always be the same. And not all users pick all the races so its got to be able to sjip those if there not there) Thanks
  17. Ya i got it working. Heres a working code for 7 divs. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <title>Show/Hide</title> <script type="text/javascript"> // <![CDATA[ function display(obj,id1,id2,id3,id4,id5,id6,id7) { txt = obj.options[obj.selectedIndex].value; document.getElementById(id1).style.display = 'none'; document.getElementById(id2).style.display = 'none'; document.getElementById(id3).style.display = 'none'; document.getElementById(id4).style.display = 'none'; document.getElementById(id5).style.display = 'none'; document.getElementById(id6).style.display = 'none'; document.getElementById(id7).style.display = 'none'; if ( txt.match(id1) ) { document.getElementById(id1).style.display = 'block'; } if ( txt.match(id2) ) { document.getElementById(id2).style.display = 'block'; } if ( txt.match(id3) ) { document.getElementById(id3).style.display = 'block'; } if ( txt.match(id4) ) { document.getElementById(id4).style.display = 'block'; } if ( txt.match(id5) ) { document.getElementById(id5).style.display = 'block'; } if ( txt.match(id6) ) { document.getElementById(id6).style.display = 'block'; } if ( txt.match(id7) ) { document.getElementById(id7).style.display = 'block'; } } // ]]> </script> </head> <body> <table width="500" cellspacing="0" cellpadding="0"> <thead> <tr> <td width="303" class="title">Select a Design Service</td> <td width="195" class="field"> <select name="type" onChange="display(this,'1','2','3','4','5','6','7');"> <option value="s" selected>Please Select...</option> <option value="1">QR Bookmaek</option> <option value="2">Twitter</option> <option value="3">Ning or Tumblr</option> <option value="4">Flyers</option> <option value="5">Business Cards or Brochure</option> <option value="6">Album or Mixtape Cover</option> <option value="7">Other</option> </select> </td> </tr> </thead> <tfoot> </tfoot> <tbody id="1" style="display: none;"> <tr><td><br> <div>1</div> </td></tr> </tbody> <tbody id="2" style="display: none;"> <tr><td><br> <div>2</div> </td></tr> </tbody> <tbody id="3" style="display: none;"> <tr><td><br> <div>3</div> </td></tr> </tbody> <tbody id="4" style="display: none;"> <tr><td><br> <div>4</div> </td></tr> </tbody> <tbody id="5" style="display: none;"> <tr><td><br> <div>5</div> </td></tr> </tbody> <tbody id="6" style="display: none;"> <tr><td><br> <div>6</div> </td></tr> </tbody> <tbody id="7" style="display: none;"> <tr><td><br> <div>7</div> </td></tr> </tbody> <tbody> </tbody> </table> </body> </html>
  18. Heads up if you use the script i linked to earlier. You CAN NOT put a table inside the table. Idk why but it doesn't work.
  19. Heres what i did! function printLB1($week){ $weeknum = 'Week'.$week; $result = mysql_query("SELECT * FROM CollegeFootballWeeklyLeaderboards ORDER BY $weeknum DESC"); while ($row = mysql_fetch_object($result)) { $username[] = $row->Username; $leaderboardPoints[] = $row->$weeknum; } $num = mysql_num_rows($result); for($i=0; $i< $num; $i++) { echo ' <tr> <td>'.$i.'.</td> <td>'.$username[$i].'</td> <td>'.$leaderboardPoints[$i].'</td> </tr> '; } } ?> <table width="68%" border="1" cellspacing="0" cellpadding="5"> <tr> <td width="14%"><strong>Position</strong></td> <td width="51%"><strong>User</strong></td> <td width="35%"><strong>Points</strong></td> </tr> <? printLB1(1); ?> </table>
  20. Heres what i got... function printLB1 (){ $result = mysql_query("SELECT * FROM leaderboards ORDER BY CollegeFootballPoints DESC"); while ($row = mysql_fetch_object($result)) { $leaderboard[] = $row->Username; $leaderboardPoints[] = $row->CollegeFootballPoints; } $num = mysql_num_rows($reault); //I know from here to ................... needs to be in a var or echo or something. <tr> <td>1.</td> //This will auto increment too like i++ but i cna do that myself! <td>echo $leaderboard;</td> <td>echo $leaderboardPoints;</td> </tr> //Here......................................................... } I need to pull a table row per user. But i want to somehow do it once in a function and then ill echo the function into a table after the php stuff is done. Like i want to pull every a table row per user in the function. then display the function below that way i don't have to write a whole extra query and table row per person. If you understand please help if not please let me know where i can explain more. Thanks
  21. I'm working on a similar problem. I found this http://bytes.com/topic/javascript/answers/88791-show-hide-text-form-field-based-drop-down-selection Look at the reply that Mrk put. His is done with tables but you can easily put your divs in the tables. In order to do what your trying to do you need javascript Like i said though i'm doing the exact same thing right now so if you go with this and get stuck let me know i've almost got it working how i need it too.
  22. On what site? I can't find it on "This site (phpfreaks.com)"
  23. I have leader boards on my site (Currently just overall) But i want o include weekly as well without showing them all at one time. So i want to create a drop down box that is like this... <form id="weekSelect" name="weekSelect" method="post" action=""> <label>Week <select name="weeks" id="weeks"> <option value="Overall">Overall</option> <option value="Week1">1</option> <option value="Week2">2</option> <option value="Week3">3</option> <option value="Week4">4</option> <option value="Week5">5</option> <option value="Week6">6</option> <option value="Week7">7</option> <option value="Week8">8</option> <option value="Week9">9</option> <option value="Week10">10</option> <option value="Week11">11</option> <option value="Week12">12</option> <option value="Week13">13</option> </select> </label> </form> A user will select which week to view and then below this a table populated with the top 20 users will show up. How do i go about making this form show a certain table depending on which week is selected? Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.