Jump to content

levidyllan

Members
  • Posts

    30
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling
  • Location
    in the corner of this sphere

levidyllan's Achievements

Member

Member (2/5)

0

Reputation

  1. I have found and used this: <?php header('Content-type: text/xml'); echo '<?xml version="1.0" encoding="UTF-8"?>'; // Set RSS version. echo ' <rss version="2.0"> '; // Start the XML. echo ' <channel> <title>???</title> <description>???</description> <link>???>/link>'; // Create a connection to your database. require_once ('connection file'); // Connect to the db. // Query database and select the last 10 entries. $data = mysql_query('SELECT * FROM ??? ORDER BY ??? DESC'); while($row = mysql_fetch_array($data)) { echo ' <item> <title>'.$row['headn'].'</title> <pubdate>'.$row['date'].'</pubdate> <description><![CDATA['.$row['news'].']]></description> <link>'.$row['link'].'</link> </item>'; } echo ' </channel> </rss>'; ?> cheers
  2. To explain what I am after heres what I want to do, a bit of background. I have a flash file that I am currently programming (AS2) which will have a section that will have dynamically loaded text. Now this text will be within a MySQl db. Now I used to have a a php file that I used for my RSS page and what this did would when called (myRss.php) would connect to the db then fetch the details I want then convert it to rss/xml and display as a RSS page. Due to stupid old me I seemed to have deleted my only copy of the php code and this would have been ideal to use for my flash inwhich to call then get the data Another way which I have not dabbeled is using php within flash direct, which could be another possibility. Any way if any body knows of any good eg's of such code this would be great many thanks me
  3. oh! you would not imagine, yup you probably would. but I find it the best way and thats how I learnt PHP etc thanks again peps :-)
  4. thanks revraz, posted as I was reply to mine as well. I went in and reduced the code and used $_SESSION['MM_Username'] = $loginUsername; and then used a simple echo to display the session on the other page and it displayed so answered that my self the best way try it... thanks so far
  5. pocobueno1388 you mentioned using the following: $_SESSION['MM_Username'] = "Their Username"; In my log in code then would I replace what I have : //declare two session variables and assign them $GLOBALS['MM_Username'] = $loginUsername; $GLOBALS['MM_UserGroup'] = $loginStrGroup; //register the session variables session_register("MM_Username"); session_register("MM_UserGroup"); with //declare two session variables and assign them $GLOBALS['MM_Username'] = $loginUsername; $GLOBALS['MM_UserGroup'] = $loginStrGroup; //register the session variables $_SESSION['MM_Username'] = "MM_Username"; $_SESSION['MM_UserGroup'] = "MM_UserGroup"; or simply do away with the globals and have the following: //register the session variables $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup; Thanks
  6. thanks guys, I will give this ago, soon and let you know if it not working, thanks again
  7. I have the following login page that logs users into another restricted page. But when i get to the next page how can I get the ID and details from the db of that member, can someone guide me in the right direction? Log in Page: <?php // *** Validate request to login to this site. session_start(); $loginFormAction = $_SERVER['PHP_SELF']; if (isset($accesscheck)) { $GLOBALS['PrevUrl'] = $accesscheck; session_register('PrevUrl'); } if (isset($_POST['userN'])) { $loginUsername=$_POST['userN']; $password=$_POST['passsW']; $MM_fldUserAuthorization = "auth"; $MM_redirectLoginSuccess = "Private.php"; $MM_redirectLoginFailed = "index.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_reConn, $reConn); $LoginRS__query=sprintf("SELECT ref_name, ref_pass, ref_auth FROM ref_members WHERE ref_name='%s' AND ref_pass='%s'", get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); $LoginRS = mysql_query($LoginRS__query, $reConn) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = mysql_result($LoginRS,0,'ref_auth'); //declare two session variables and assign them $GLOBALS['MM_Username'] = $loginUsername; $GLOBALS['MM_UserGroup'] = $loginStrGroup; //register the session variables session_register("MM_Username"); session_register("MM_UserGroup"); if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?> thanks in advance
  8. thanks for the reply, but I put one name in that I have in my db, isAuthorized("steve,",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup']) But it still diverts to the not authorised page. Surley if I put an echo out such as "echo $_SESSION['MM_Username']" this should display the session variable that should be passed through my log in page, but nothing displays... aaaarrhhhg! thanks
  9. thanks for the reply, but what do I need to do if anything etc
  10. I am trying to do a restricted page with regards to access levels, but seems to be having a problem. HISTORY: On a Mac using Localhost, and using Dreamweaver to impliment the code. It does the log in page with no problems then goes to the associated page. Then when I add the restrict user with access level, to this page and it just goes to the failed access page Please see the code(s) below, so can someone guide me in the right way. I beleive the Sessions are not being passed to this page?? CODE FOR RESTRICTED PAGE: <?php session_start(); $MM_authorizedUsers = "Administrator"; $MM_donotCheckaccess = "false"; // *** Restrict Access To Page: Grant or deny access to this page function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { // For security, start by assuming the visitor is NOT authorized. $isValid = False; // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. // Therefore, we know that a user is NOT logged in if that Session variable is blank. if (!empty($UserName)) { // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. // Parse the strings into arrays. $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } // Or, you may restrict access to only certain users based on their username. if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && false) { $isValid = true; } } return $isValid; } $MM_restrictGoTo = "FailedPage.php"; if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) { $MM_qsChar = "?"; $MM_referrer = $_SERVER['PHP_SELF']; if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&"; if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) $MM_referrer .= "?" . $QUERY_STRING; $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer); header("Location: ". $MM_restrictGoTo); exit; } ?> to help the code fro the log in page is below as well. LOG IN PAGE CODE: <?php// *** Validate request to login to this site. session_start(); $loginFormAction = $_SERVER['PHP_SELF']; if (isset($accesscheck)) { $GLOBALS['PrevUrl'] = $accesscheck; session_register('PrevUrl'); } if (isset($_POST['userN'])) { $loginUsername=$_POST['userN']; $password=$_POST['passsW']; $MM_fldUserAuthorization = "ref_id"; $MM_redirectLoginSuccess = "refPrivate.php"; $MM_redirectLoginFailed = "noPage.htm"; $MM_redirecttoReferrer = false; mysql_select_db($database_reConn, $reConn); $LoginRS__query=sprintf("SELECT ref_name, ref_pass, ref_id FROM ref_members WHERE ref_name='%s' AND ref_pass='%s'", get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); $LoginRS = mysql_query($LoginRS__query, $reConn) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = mysql_result($LoginRS,0,'ref_id'); //declare two session variables and assign them $GLOBALS['MM_Username'] = $loginUsername; $GLOBALS['MM_UserGroup'] = $loginStrGroup; //register the session variables session_register("MM_Username"); session_register("MM_UserGroup"); if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?> Thanks in advance
  11. I have created a contact form for a client, and well everything works fine, as I have tested it on my web space first, but now everything is on their web space/server the form works fine but I do not get any on the testing e-mails Any ideas on this ?
  12. cheers Wildteen88, wil give it a try:-)
  13. I was asked this question today and well thought I woud research it. Can we connect to a database(mySQL) using php, on another site. IE: siteOne.co.uk runs some script that can connect to siteTwo.co.uk mysql database, therefore looking as its got is own etc? Any ideas or a straight NO. I did mention about running a php to xml page that reads the db and converts it to an xml page and then it can get the data from there with absolute path etc ?
  14. thanks for this I knew it had to be a return operator but for the life of me could not find the right eg in google typical many thanks wil let you know either way if ok or aaarrrhhh!
  15. I have created an image resize code into a function which saves me outputing the code four times as my form has four image inputs. Anyway at then end of this function I have an echo section that displays the image resized ( 4 in all images as function is called 4 times). Anyway I would like to return the image name after the function is run, but not sure how to get this info. The following code is the function: function resize($name){ $size = 150; // the thumbnail height $filedir = 'pics/'; // the directory for the original image $thumbdir = 'pics/'; // the directory for the thumbnail image $prefix = 'thumbs_'; // the prefix to be added to the original name $maxfile = '2000000'; $mode = '0666'; $userfile_name = $_FILES[$name]['name']; $userfile_tmp = $_FILES[$name]['tmp_name']; $prod_img = $filedir.$userfile_name; $prod_img_thumb = $thumbdir.$prefix.$userfile_name; move_uploaded_file($userfile_tmp, $prod_img); chmod ($prod_img, octdec($mode)); $sizes = getimagesize($prod_img); $aspect_ratio = $sizes[1]/$sizes[0]; if ($sizes[1] <= $size) { $new_width = $sizes[0]; $new_height = $sizes[1]; }else{ $new_height = $size; $new_width = abs($new_height/$aspect_ratio); } $destimg=ImageCreateTrueColor($new_width,$new_height) or die('Problem In Creating image:' . $name); $srcimg=ImageCreateFromJPEG($prod_img) or die('Problem In opening Source Image: '. $name); ImageCopyResized($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg)) or die('Problem In resizing: '. $name); ImageJPEG($destimg,$prod_img_thumb,90) or die('Problem In saving: '. $name); imagedestroy($destimg); unlink($destimg);//Delete the original image echo '<a href="'.$prod_img.'"> '; echo '<img src="'.$prod_img_thumb.'" width="'.$new_width.'" heigt="'.$new_height.'"> '; echo ' </a><br /><br />'; } The follwoing code calls the function: if (isset($_FILES['image']['name'])) { resize("image");//resize function } Now, after the function is run I would like to some how obtain the image name "$prod_img_thumb" so I can place in a variable to use later etc, how can I return the $prod_img_thumb value from out the function?
×
×
  • 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.