PHP - Grabbing A Ever Changing List Of People From A Website! Is It Possible?
I've had this concept for something I've been wanting to do for awhile, but I need to know if it's even possible in PHP. I've been seriously playing with PHP for a few months now and here's what I was wanting to do.
On this website there is a list of players currently online http://www.tibia.com/community/?subtopic=worlds&world=Solera Is there anyway I could grab those list of players and store their names into a .txt file? This is just for fun. My actual goal is to create something that's grabbing that list of players every 5 minutes and showing me who has logged off and who has logged on. Similar TutorialsI'm a developer, I don t know how to think like the consumer? What do they know? What do they want? It s hard in a way to explain something complex in layman s terms, I mean yes it is easy, you take files, put them on the internet, others can view them. Fine. But when they want a website, what should I expect? I mean, it seems like I can t ask them to even "draw a design on paper" for me to translate into a website which I prefer. Wireframes are nice, like drag and drop, I m looking to build one of those with automatic database creation/ pointing with injection protection. Anyway, it does depend on what their business is about, I think their mission statement or goal as a business is what determines the functionality and presentation of the website. If you want a website, what do you want? What are you looking for? Is There a script which can be used that will grab constantly updated information from a certain website, and output it onto your own website? By constantly, I mean like: 23 Hours, 13 Minutes and 3 seconds ago. Surely this can be done some how? Thanks Could I use: $page_contents = file_get_contents("http://www.example.com"); if i wanted to look for <td>time:</td> $matches = array(); preg_match('CODE TO LOOK FOR HERE?', $page_contents, $matches); echo $matches[0]; Hi There, I would like my webpage title to change for each sub-site that I visit say I go to player A I want the website name to say CNGHLDB-Player A and If I go to player B profile it would change to say CNGHLDB-Player B I have the names in my php script so I am assuming it shouldn't be to hard to do the coding for it, but I am not sure how to do it. <title>CNGHLDB</title> </head> <? // Connects to your Database mysql_connect("", "", "") or die(mysql_error()); mysql_select_db("") or die(mysql_error()); //Get PlayerID from URL $iPlayerID = $_GET["PlayerID"]; $iNationID = $_GET["NationID"]; $oPlayerInfo = mysql_query(" SELECT Players.PlayerID, Players.FirstName, Players.LastName, Players.Position, Players.Height, Players.Weight, Players.DOB, CNGHLTeams.CNGHLRights, NHLTeams.Team, Players.CNDraftYR, DraftTeam.DraftID, Players.CNDraftPOS, Countries.Nation, Players.NationID, DraftTeam.DrTeam FROM Players Left JOIN CNGHLTeams ON Players.CNGHLID=CNGHLTeams.CNGHLID Left JOIN NHLTeams ON Players.TeamsID=NHLTeams.TeamID Left JOIN Countries ON Players.NationID=Countries.NationID Left JOIN DraftTeam ON Players.DraftID=DraftTeam.DraftID WHERE Players.PlayerID=$iPlayerID ORDER BY Players.LastName; ") or die(mysql_error()); while($row = mysql_fetch_array($oPlayerInfo)) { Print "<body>"; ECHO "<div align='center'>"; ECHO "<table width='496' border='0'>"; ECHO "<tr>"; ECHO "<td width='148'><div align='center'><a href=\"http://www.cnghl.org/cnghldb/index.php\"><strong>SEARCH PLAYERS</strong></a></div></td>"; ECHO "<td width='152'><div align='center'><a href=\"http://www.cnghl.org/cnghldb/goaliesearch.php\"><strong>SEARCH GOALIES</strong></a></div></td>"; ECHO "<td width='182'><div align='center'><strong><a href=\"http://www.cnghl.biz/history/league.html\">FRANCHISE HISTORY</a></strong></div></td>"; ECHO "</tr> </table> </div> <p align='center'> </p> <p>"; Print "<center> </p> <div align='center'> <table width='700' border='0'> </center>"; Print "<tr>"; Print "<td colspan='3'><h1>".$row['FirstName']." ".$row['LastName']." <img src=\"http://www.cnghl.org/cnghldb/nation/".$row['NationID'].".gif\"></h1></td>"; Print "</tr>"; Print "<tr>"; Print "<td width='300' height='26'><strong>Birthdate: </strong>".$row['DOB']."</td>"; $DOB = $row[DOB]; //dd.mm.yyyy $user_date = new DateTime($DOB); $curr_date = new DateTime(); $age_cal = $curr_date->diff($user_date); Print "<td width='525'><strong>Age: </strong>".$age_cal->y;"</td>"; Print "<td style='vertical-align:top;'width='275' rowspan='10'><div align='center'><img src=\"http://www.cnghl.org/cnghldb/images/".$iPlayerID.".jpg\">"; Print "</tr>"; Print "<tr>"; Print "<td><strong>Nation: </strong>".$row['Nation']."</td>"; Print "<td><strong>CNGHL Team: </strong>".$row['CNGHLRights']. "</td>"; Print "</tr>"; Print "<tr>"; Print "<td><strong>Position: </strong>".$row['Position']. "</td>"; Print "<td><strong>Weight: </strong>".$row['Weight']. "</td>"; Print "</tr>"; Print "<tr>"; Print "<td><strong>Height: </strong>".$row['Height']. "</td>"; Print "<td><strong>NHL Team: </strong>".$row['Team']. "</td>"; Print "</tr>"; Print "<tr>"; Print "<td><strong>Draft Year: </strong>".$row['CNDraftYR']."</td>"; Print "<td><strong>Draft Position: </strong>".$row['CNDraftPOS']."</td>"; Print "</tr>"; Print "<tr>"; Print "<td><strong>Drafted By: </strong>".$row['DrTeam']."</td>"; Print "<td> </td>"; Print "</tr>"; Print " <tr> <td height='179' colspan='2'> </td> </tr> The coding that pulls there names that I would want to use is Firstname and Lastname or I have the simpler full name that include both first and last names. Thanks for your help! Edited by mac_gyver, 10 June 2014 - 03:36 AM. code tags around code please Unfortunately, I have got nearly zero knowledge in PHP. I'm just trying to add a drop-down menu on my website which will turn the prices in USD to other currencies. I'm trying hard to learn but it's too difficult for me at the moment. Here are codes written by someone else which I want to modify and apply to my website. I've tried the second PHP on my WAMP local server but it returns nothing. Both files were in the same folder. I don't know if these codes are correct. I'd appreciate if someone could tell me if the codes are wrong or they just don't work on WAMP server. Sorry the codes are quite long. Thanks in advance. Code: [Select] <?php /* File: currencyexchange.php Author: Gary White Last modified: July 6, 2005 Copyright (C) 2005, Gary White This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the included GNU General Public License for more details. If you received this file without the gpl.txt file, you may view it at: http://www.gnu.org/copyleft/gpl.html See the readme.txt file for usage. July 6, 2005 added the RON, Romania New Leu, to the currency list. */ // this simply gets an array of possible currency countries and names $allCurrencies=getCurrencyNames(); class currencyExchange{ ///////////////////////////////////////////////////////////////////////////////////////// // Public Properties // Note that these properties are public, but the values are all generated internally. // You should consider them read only during normal usage. // The only one you may want to access would be the $localFile property, if you wanted // to change the name of the local file used to cache a copy of the data. ///////////////////////////////////////////////////////////////////////////////////////// // $Supplier property will be the European Central Bank, assuming we get the data var $Supplier=""; // $Date property is the date of the exchange rate publication var $Date=""; // $Rates property is an associative array of rateobj objects with the three letter identifier as the array keys var $Rates=array(); // $Source property will be either "Local" or "Remote" depending on where the data comes from var $Source=""; // $Error property will contain any error messages generates along the way var $Error=""; // $localFile property is the file name used to cache a local copy of the XML file var $localFile="currencies_local.xml"; // $url property is the URL of the XML file at the European Central Bank var $url="http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml"; ///////////////////////////////////////////////////////////////////////////////////////// // Public Methods ///////////////////////////////////////////////////////////////////////////////////////// function getData(){ $olderr=error_reporting(0); $this->Source="Local"; if(file_exists($this->localFile)){ // load it $this->xml=@file_get_contents($this->localFile); $this->parse(); // check if it's a weekend // what day of the week is it? $weekday=date("w"); // if it's a Sunday or Saturday if($weekday==0 || $weekday==6){ // go back to last Friday $date=date("Y-m-d",strtotime("last Friday")); } else { $date=date("Y-m-d"); } // if the date in the local file is not the same // as our current date, or last Friday for weekends if($this->Date!=$date){ // clear the data $this->clearData(); // get the remote file $this->xml=$this->getRemoteFile($this->url); if($this->parse()){ $this->Source="Remote"; // write the remote file data to a local copy of the file $this->saveLocalCopy(); } } // if we have a local copy }else{ $this->xml=$this->getRemoteFile($this->url); if($this->xml) // write the remote file data to a local copy of the file $this->saveLocalCopy(); } if(!$this->xml) $this->error="Failed to get data"; else{ $this->parse(); } // sort our rates on the keys ksort($this->Rates); error_reporting($olderr); return count($this->Rates); } function getRemoteFile($url){ $curl_handle = curl_init(); // Where should we get the data? curl_setopt ($curl_handle, CURLOPT_URL, $url); // This says not to dump it directly to the output stream, but instead // have it return as a string. curl_setopt ($curl_handle, CURLOPT_RETURNTRANSFER, 1); // the following is optional, but you should consider setting it // anyway. It prevents your page from hanging if the remote site is // down. curl_setopt ($curl_handle, CURLOPT_CONNECTTIMEOUT, 1); // Now, YOU make the call. $buffer = curl_exec($curl_handle); // And tell it to shut down (when your done. You can always make more // calls if you want.) curl_close($curl_handle); // This is where i�d probably do some extra checks on what i just got. // Paranoia pays dividends. return $buffer; } function Convert($from, $to, $amount=1){ // Converts from one currency to another. The method expects at least two // parameters. The first param , $from, it the three letter identifier for // the currency you are converting from. The second param, $to, is the // three letter identifier for the currency you are converting to. The final // param, $amount, is the amount of the $from currency to convert. If omitted // the amount defaults to 1 and the function will return the amount of $to // currency that corresponds with 1 unit of the $from currency. if(array_key_exists($from, $this->Rates) && array_key_exists($to, $this->Rates)){ return ($amount * (($this->Rates[$to]->rate)/($this->Rates[$from]->rate))); }else{ $this->Error->Error = ""; if (!array_key_exists($from, $this->Rates)) $this->Error.="$from is not a recognized currency identifier "; if (!array_key_exists($from, $this->Rates)) $this->Error.="$to is not a recognized currency identifier"; return false; } } function setBaseCurrency($currency){ // This function converts all currencies to be based on one unit of // $base currency. It's only really useful if you want to output a // table of conversion factors. // get a factor to do our conversion based on our base currency $factor=$this->Rates[$currency]->rate; // modify the rates based on the base currency foreach(array_keys($this->Rates) as $k){ $rate=$this->Rates[$k]->rate / $factor; $this->Rates[$k]->rate=$rate; } return (count($this->Rates)>0); } ///////////////////////////////////////////////////////////////////////////////////////// // Private Methods // You should not need to call any of the following methods. ///////////////////////////////////////////////////////////////////////////////////////// function clearData(){ $this->Supplier=""; $this->Date=""; $this->Rates=array(); $this->Source=""; $this->xml=""; } function saveLocalCopy(){ $fp=fopen($_SERVER['DOCUMENT_ROOT'].$this->localFile,"w") or die("failed to write file"); fwrite($fp,$this->xml); fclose($fp); $this->parse(); $this->Source="Remote"; } function parse(){ if($this->xml){ $this->parser = xml_parser_create(); @xml_set_object($this->parser, $this); @xml_set_element_handler($this->parser, "startElement", "endElement"); @xml_set_character_data_handler($this->parser, "characterData"); $this->Rates['EUR']=new rateobj(); $this->Rates['EUR']->rate=1.00; $this->Rates['EUR']->currency="Euro"; xml_parse($this->parser, $this->xml, true) or die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($parser)), xml_get_current_line_number($parser))); xml_parser_free($this->parser); } } function currencyExchange(){ $dir=pathinfo($_SERVER['PHP_SELF']); $dir=$dir['dirname']; $this->localFile="$dir/$this->localFile"; } function startElement($parser, $name, $attrs) { global $allCurrencies; $this->temp=""; $gwCurrencyExch=&$GLOBALS['gwCurrencyExch']; if($name=="CUBE"){ if(array_key_exists("TIME",$attrs)){ $this->Date=$attrs["TIME"]; } if(array_key_exists("CURRENCY",$attrs)){ $this->Rates[$attrs["CURRENCY"]]=new rateobj(); $this->Rates[$attrs["CURRENCY"]]->rate=$attrs["RATE"]; $this->Rates[$attrs["CURRENCY"]]->currency=$allCurrencies[$attrs["CURRENCY"]]; } } } function characterData($parser, $data){ $this->temp.=$data; } function endElement($parser, $name) { switch($name){ case "GESMES:NAME": $this->Supplier=$this->temp; break; case "GESMES:SUBJECT": $this->Report=$this->temp; break; } $temp=""; } } // end of ratelist class class gwSocket{ var $ClassName="gwSocket"; var $Version="0.6"; var $error=""; var $headers; var $maxRedirects=3; var $page=""; var $result=""; var $redirects=0; var $userAgent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"; function getUrl( $url ) { $retVal=""; $url_parsed = parse_url($url); $scheme = $url_parsed["scheme"]; $host = $url_parsed["host"]; $port = $url_parsed["port"]?$url_parsed["port"]:"80"; $user = $url_parsed["user"]; $pass = $url_parsed["pass"]; $path = $url_parsed["path"]?$url_parsed["path"]:"/"; $query = $url_parsed["query"]; $anchor = $url_parsed["fragment"]; if (!empty($host)){ // attempt to open the socket if($fp = fsockopen($host, $port, $errno, $errstr, 2)){ $path .= $query?"?$query":""; $path .= $anchor?"$anchor":""; // this is the request we send to the host $out = "GET $path ". "HTTP/1.0\r\n". "Host: $host\r\n". "Connection: Close\r\n". "User-Agent: $this->userAgent\r\n"; if($user) $out .= "Authorization: Basic ". base64_encode("$user:$pass")."\r\n"; $out .= "\r\n"; fputs($fp, $out); while (!feof($fp)) { $retVal.=fgets($fp, 128); } fclose($fp); } else { $this->error=$errstr; } $this->result=$retVal; $this->headers=$this->parseHeaders(trim(substr($retVal,0,strpos($retVal,"\r\n\r\n")))); $this->page=trim(stristr($retVal,"\r\n\r\n"))."\n"; if(isset($this->headers['Location'])){ $this->redirects++; if($this->redirects<$this->maxRedirects){ $location=$this->headers['Location']; $this->headers=array(); $this->result=""; $this->page=""; $this->getUrl($location); } } } return (!$retVal=""); } function parseHeaders($s){ $h=preg_split("/[\r\n]/",$s); foreach($h as $i){ $i=trim($i); if(strstr($i,":")){ list($k,$v)=explode(":",$i); $hdr[$k]=substr(stristr($i,":"),2); }else{ if(strlen($i)>3) $hdr[]=$i; } } if(isset($hdr[0])){ $hdr['Status']=$hdr[0]; unset($hdr[0]); } return $hdr; } } // end of gwSocket class class rateobj{ var $currency=""; var $rate=0; } function getCurrencyNames(){ $retVal['AED']="United Arab Emirates Dirham"; $retVal['AFA']="Afghanistan Afghani"; $retVal['ALL']="Albania Leke"; $retVal['ARS']="Argentina Peso"; $retVal['ATS']="Austria Schilling*"; $retVal['AUD']="Australia Dollar"; $retVal['BBD']="Barbados Dollar"; $retVal['BDT']="Bangladesh Taka"; $retVal['BEF']="Belgium Franc*"; $retVal['BGN']="Bulgaria Leva"; $retVal['BHD']="Bahrain Dinar"; $retVal['BMD']="Bermuda Dollar"; $retVal['BRL']="Brazil Reai"; $retVal['BSD']="Bahamas Dollar"; $retVal['CAD']="Canada Dollar"; $retVal['CHF']="Switzerland Franc"; $retVal['CLP']="Chile Peso"; $retVal['CNY']="China Yuan Renminbi"; $retVal['COP']="Colombia Peso"; $retVal['CRC']="Costa Rica Colone"; $retVal['CYP']="Cyprus Pound"; $retVal['CZK']="Czech Republic Koruny"; $retVal['DEM']="Germany Deutsche Mark*"; $retVal['DKK']="Denmark Kroner"; $retVal['DOP']="Dominican Republic Peso"; $retVal['DZD']="Algeria Dinar"; $retVal['EEK']="Estonia Krooni"; $retVal['EGP']="Egypt Pound"; $retVal['ESP']="Spain Peseta*"; $retVal['EUR']="Euro"; $retVal['FIM']="Finland Markkaa*"; $retVal['FJD']="Fiji Dollar"; $retVal['FRF']="France Franc*"; $retVal['GBP']="United Kingdom Pound"; $retVal['GRD']="Greece Drachmae*"; $retVal['HKD']="Hong Kong Dollar"; $retVal['HRK']="Croatia Kuna"; $retVal['HUF']="Hungary Forint"; $retVal['IDR']="Indonesia Rupiahs"; $retVal['IEP']="Ireland Pounds*"; $retVal['ILS']="Israel New Shekel"; $retVal['INR']="India Rupee"; $retVal['IQD']="Iraq Dinar"; $retVal['IRR']="Iran Rial"; $retVal['ISK']="Iceland Kronur"; $retVal['ITL']="Italy Lire*"; $retVal['JMD']="Jamaica Dollar"; $retVal['JOD']="Jordan Dinar"; $retVal['JPY']="Japan Yen"; $retVal['KES']="Kenya Shilling"; $retVal['KRW']="South Korea Won"; $retVal['KWD']="Kuwait Dinar"; $retVal['LBP']="Lebanon Pound"; $retVal['LKR']="Sri Lanka Rupee"; $retVal['LTL']="Lithuanian Lita"; $retVal['LVL']="Latvian Lat"; $retVal['LUF']="Luxembourg Franc*"; $retVal['MAD']="Morocco Dirham"; $retVal['MTL']="Malta Liri"; $retVal['MUR']="Mauritius Rupee"; $retVal['MXN']="Mexico Peso"; $retVal['MYR']="Malaysia Ringgit"; $retVal['NLG']="Dutch (Netherlands) Guilder*"; $retVal['NOK']="Norway Kroner"; $retVal['NZD']="New Zealand Dollar"; $retVal['OMR']="Oman Rial"; $retVal['PEN']="Peru Nuevos Sole"; $retVal['PHP']="Philippines Peso"; $retVal['PKR']="Pakistan Rupee"; $retVal['PLN']="Poland Zlotych"; $retVal['PTE']="Portugal Escudo*"; $retVal['QAR']="Qatar Riyal"; $retVal['ROL']="Romania Lei"; $retVal['RON']="Romania New Leu"; $retVal['RUB']="Russia Ruble"; $retVal['SAR']="Saudi Arabia Riyal"; $retVal['SDD']="Sudan Dinar"; $retVal['SEK']="Sweden Kronor"; $retVal['SGD']="Singapore Dollar"; $retVal['SIT']="Slovenia Tolar"; $retVal['SKK']="Slovakia Koruny"; $retVal['THB']="Thailand Baht"; $retVal['TND']="Tunisia Dinar"; $retVal['TRL']="Turkey Lira*"; $retVal['TRY']="Turkey New Lira"; $retVal['TTD']="Trinidad and Tobago Dollar"; $retVal['TWD']="Taiwan New Dollar"; $retVal['USD']="United States Dollar"; $retVal['VEB']="Venezuela Bolivare"; $retVal['VND']="Vietnam Dong"; $retVal['XAF']="CFA BEAC Franc"; $retVal['XAG']="Silver Ounce"; $retVal['XAU']="Gold Ounce"; $retVal['XCD']="Eastern Caribbean Dollar"; $retVal['XDR']="IMF Special Drawing Right"; $retVal['XOF']="CFA BCEAO Franc"; $retVal['XPD']="Palladium Ounce"; $retVal['XPF']="CFP Franc"; $retVal['XPT']="Platinum Ounce"; $retVal['ZAR']="South Africa Rand"; $retVal['ZMK']="Zambia Kwacha"; return $retVal; } ?> Code: [Select] <?php /* This is a sample file that demonstrates the usage of the currencyExchange class. For purposes of this example, make certain that currencyexchange_class.php is saved in the same directory as this file. */ //error_reporting(0); $path=pathinfo($_SERVER['PHP_SELF']); $path=$_SERVER['DOCUMENT_ROOT'].$path['dirname']; require_once("$path/currencyexchange_class.php"); $cx=new currencyExchange(); $cx->getData(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="imagetoolbar" content="no"> <meta name="mssmarttagspreventparsing" content="true"> <meta http-equiv="MSThemeCompatible" content="No"> <title>Currency Conversion Example</title> <style type="text/css"> body{ background-color: #eee; color: #333; font: small Verdana, Arial, Helvetica, sans-serif } #pricebox{ background-color: #f7f7f7; border:1px solid #000; margin: 50px auto; padding: 10px; width: 300px; } #pricebox h1, #pricebox h2, #pricebox p{ margin: 0; padding: 0; text-align: center; } h1{font-size: 160%;} h2{font-size: 140%;} </style> </head> <body> <div id="pricebox"> <h1>Get the New Widget</h1> <h2>Price $250.00 U.S. dollars</h2> <p><?php if ($euro=$cx->Convert("USD","EUR",250)){ $euro=number_format($euro,2); echo "€$euro Euros "; } if ($pound=$cx->Convert("USD","GBP",250)){ $pound=number_format($pound,2); echo "<br>\n£$pound British Pounds</p>\n" ."<p style=\"font-size:smaller;border-top: 1px solid #666;\">Non U.S. pricing based on exchange rates<br>\nin effect as of $cx->Date"; } ?></p></div> </body> </html> Hello. I am working on something where I don't want to do this.... if ($pages <= 1){$P=1;} elseif ($pages > 1 && $pages <= 2){$P=2;} elseif ($pages > 2 && $pages <= 3){$P=3;} elseif ($pages > 3 && $pages <= 4){$P=4;} elseif ($pages > 4 && $pages <= 5){$P=5;} elseif ($pages > 5 && $pages <= 6){$P=6;} elseif ($pages > 6 && $pages <= 7){$P=7;} elseif ($pages > 7 && $pages <= 8){$P=8;} elseif ($pages > 8 && $pages <= 9){$P=9;} elseif ($pages > 9 && $pages <= 10){$P=10;} This could go on and on and I would rather use the for $ i++ for this so it will wright out the coding for as little or as much as it needs rather then I. However I am not sure how I would do this. I also have if ($PN == 1){$L = "0,20";} elseif ($PN == 2){$L = "20,20";} elseif ($PN == 3){$L = "40,20";} elseif ($PN == 4){$L = "60,20";} elseif ($PN == 5){$L = "80,20";} elseif ($PN == 6){$L = "100,20";} were I will need to be able to add 20 to the number. Is this easily done? I'm a bit loss tried a few things and its not working properly. Hello everyone!
I'm a web design student who's trying to learn some PHP, JavaScript and stuff! You'll probably find me asking more questions than helping people, apologies in advance!
and doing sql injections i have enabled mysql logging and i can find where they did the query, but it only shows the query, it doesn't show what location or what url or how they did it so how can i fix it? thanks also lighttpd logs doesn't show... this sucks Hey all, I've been coding a thing for my website which allows Users to apply for a crew via the Crew Profile Page. The code all works just when the User applys I want the Crew Staff to get a message just to let them know. I've tryed things of which I though could work but none of them did. I also tryed with a function, witch didn't work but I'm not to sure on Functions at the moment. My Code so far: <?php session_start(); include "includes/config.php"; include "includes/functions.php"; include "includes/bb-codes.php"; logincheck(); $username= $_SESSION['username']; $viewcrew= $_GET['viewcrew']; $fetch=mysql_fetch_object(mysql_query("SELECT * FROM crews WHERE name='$viewcrew'")); $mysql1 = mysql_query("SELECT * FROM `users` WHERE username = '$username'") or die ("Error, Line 13 " . mysql_error()); // Doing User Query $userfetch = mysql_fetch_object($mysql1); // Getting User Object $needcrewstaff = mysql_query("SELECT * FROM crews WHERE name='$viewcrew'"); $pleasework = mysql_fetch_object($needcrewstaff); // Start Send Staff Message Function function sendstaffmessage(){ $message = "You have an Crew Application. Click <a href='crewapp.php' target='mainFrame'>here</a> to Accept or Decline it!"; if ($pleasework->owner == $username){ mysql_query("INSERT INTO `inbox` ( `id` , `to` , `from` , `message` , `date` , `read` , `saved` , `event_id` ) VALUES ( '', '$pleasework->owner', '$username', '$message', '$date', '0', '0', '0' )"); } if ($pleasework->coowner == $username){ mysql_query("INSERT INTO `inbox` ( `id` , `to` , `from` , `message` , `date` , `read` , `saved` , `event_id` ) VALUES ( '', '$pleasework->owner', '$username', '$message', '$date', '0', '0', '0' )"); } if ($pleasework->underboss == $username){ mysql_query("INSERT INTO `inbox` ( `id` , `to` , `from` , `message` , `date` , `read` , `saved` , `event_id` ) VALUES ( '', '$pleasework->underboss', '$username', '$message', '$date', '0', '0', '0' )"); } if ($pleasework->recruiter == $username){ mysql_query("INSERT INTO `inbox` ( `id` , `to` , `from` , `message` , `date` , `read` , `saved` , `event_id` ) VALUES ( '', '$pleasework->recruiter', '$username', '$message', '$date', '0', '0', '0' )"); } if ($pleasework->recruiterone == $username){ mysql_query("INSERT INTO `inbox` ( `id` , `to` , `from` , `message` , `date` , `read` , `saved` , `event_id` ) VALUES ( '', '$pleasework->recruiterone', '$username', '$message', '$date', '0', '0', '0' )"); } } // End the Function! if (strip_tags($_POST['apply'])){ if ($userfetch->crew != "0"){ echo ("You can not Apply for <strong>$viewcrew</strong> when already being in <strong>$get->crew</strong>!"); }else{ sendstaffmessage(); mysql_query("UPDATE users SET crewapp='$viewcrew' WHERE username='$username'"); echo ("$viewcrew Applied for! - Note: If you Apply for a different Crew this App will be Deleted."); } } ?> Is there any way to change my code which will send the Crew Boss etc.. a Message when somebody has applyed? Thanks for any help. I don't even know if this is physically possible due to latency, mechanical, etc...
But, the way my website is planned at the moment, a person submits basic info, hits "Create account" and then is taken to a new page with that basic information and an incremented unique id, based on last unique id entry read from database.
My concern is that if two people or more were making accounts within the same time frame and one person hits "Create account" before another person does, what if the wrong data is pulled? The unique ID I guess is the only thing being pulled, if 0, start at 1, whatever But I wonder if I can temporarily hold data between two webpages before it is stored in the database finally when all fields have been filled. Thanks for any help / ideas I have a script where you add an entry into a DB. I want to take everyone from another table in this DB and send the newly added content to them. My problem is displaying all of the contacts into the $to= location. This is what I currently have: <?php error_reporting(-1); //-------------email section----------------// $title = $_POST['title']; $story = $_POST['story']; $date = $_POST['date']; //do { //$to = $row_Fake['fake_email']; //} //while($row_Fake = mysql_fetch_assoc($Fake)); while ($row_Fake = mysql_fetch_assoc($Fake)) { $to = $row_Fake['fake_email']; } //$to = "colinrblambert@gmail.com"; $subject = "New Halnor Update!"; $message = " <html> <head> <title>New Update!</title> </head> <body> <div align='center'>"; //do{ echo $row_Fake['fake_email'].", "; } while($row_Fake = mysql_fetch_assoc($Fake)); //$row['fake_email']; "We have a new update from ".$date." to share with you !<br /><br /> <table border='0'> <tr> <td valign='top' width='200'><b>".$title."</b></td> <td>".nl2br($story)."</td> </tr> </table> </div> </body> </html> "; $x = 1; $str = "test"; do{ $str .= $x; $x++; }while($x<10); // Always set content-type when sending HTML email $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; // More headers $headers .= 'From: <admin@website.com>'. "\r\n"; //$headers .= 'Cc: myboss@example.com' . "\r\n"; mail($to,$subject,$message,$headers); } header(sprintf("Location: %s", $insertGoTo)); } ?>Kind of lost right now. Can someone help? Hi guys. I'm very new to PHP, and I'm trying to create a simple mail script. Mail a friend A user will click an image on the site which will open a pop up box. They input their name and the email of the friend that they want to send the current URL to. The email will send the current URL via email and display a confirmation message once it has sent successfully. The friend will receive an email with a link to the URL. The problem The email part works fine, it's the URL in the message that is the issue. When the user clicks the 'Email a friend' it opens a popup box - which is where the URL is being grabbed from and emailed. Is there a way to grab the URL from the page before the popup? Here is my (rather amateur) code. Also, feel free to let me know if I can make improvements to it if anything seems a bit strange! The popup link: <a onclick="window.open(this.href,'win2','width=400,height=350,menubar=yes,resizable=yes'); return false;" title="E-mail" href="mailform/form.html">Send to a friend</a> The popup form: <html> <body> <form method="post" action="code.php"> Friends Email: <input name="email" type="text" /><br /> Your Name: <input name="name" type="text" /><br /> <input type="submit" /> </form> </body> </html> The PHP code: <?php // Declaring Variables $email = $_REQUEST['email'] ; $name = $_REQUEST['name']; $geturl = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; $message = "Hello. $name has suggested a page for you to view on our website. Please click the following link: $geturl"; // Email Settings mail( $email, "Send page to a friend", $message, "From: Timaru District Council" ); header( "Location: http://www.c4clever.com/sandbox/mailform/sent.html" ); // Confirmation page (Change this to appropriate URL) ?> Feel free to test it out if you want to (http://www.c4clever.com/sandbox) Looking forward to replies, thanks in advance! Hi guys...
I was at home and doing some coding and stumbled across and API for a computer game called Battlefield 4
http://api.bf4stats....ApRiL&output=js;
I was checking it out and it is a LOT of data. I was wondering if its possible to only pull certain data from the API, say for instance you only want to pull your user name, ID, and what game you are playing (those are the top 3 things). How would you pull only those 3 stats and display that information on say a webpage for you?
thanks guys
JL
I have this setup, but for some reason it displays the stats from user where it should display user1. Code: [Select] <?php $user = "S U O M I"; $user1 = "Tezz"; if(isset($_GET['user'])) { if(!empty($_GET['user'])) { $user = $_GET['user']; } } if(isset($_GET['user1'])) { if(!empty($_GET['user1'])) { $user1 = $_GET['user1']; } } //Skill Grabs $order = array("Overall", "Attack", "Defence", "Strength", "Hitpoints", "Ranged", "Prayer", "Magic", "Cooking", "Woodcutting", "Fletching", "Fishing", "Firemaking", "Crafting", "Smithing", "Mining", "Herblore", "Agility", "Thieving", "Slayer", "Farming", "Runecraft", "Hunter", "Construction", "Summoning", "Dungeoneering"); $get = file_get_contents("http://hiscore.runescape.com/index_lite.ws?player=$user"); $get = explode("\n", $get); $i = 0; foreach ($order as $key => $value) { $value = strtolower($value); $temp = explode(",", $get[$i]); $temp = array("rank" => $temp[0], "level" => $temp[1], "exp" => $temp[2]); $stats[$value] = $temp; $eval = "\$$value = array(\$temp[\"rank\"], \$temp[\"level\"], \$temp[\"exp\"]);"; eval($eval); $i++; } //End Skill Grabs $order1 = array("Overall", "Attack", "Defence", "Strength", "Hitpoints", "Ranged", "Prayer", "Magic", "Cooking", "Woodcutting", "Fletching", "Fishing", "Firemaking", "Crafting", "Smithing", "Mining", "Herblore", "Agility", "Thieving", "Slayer", "Farming", "Runecraft", "Hunter", "Construction", "Summoning", "Dungeoneering1"); $get1 = file_get_contents("http://hiscore.runescape.com/index_lite.ws?player=$user1"); $get1 = explode("\n", $get1); $i1 = 0; foreach ($order1 as $key1 => $value1) { $value1 = strtolower($value1); $temp1 = explode(",", $get[$i1]); $temp1 = array("rank1" => $temp1[0], "level1" => $temp1[1], "exp1" => $temp1[2]); $stats1[$value1] = $temp1; $eval1 = "\$$value1 = array(\$temp1[\"rank1\"], \$temp1[\"level1\"], \$temp1[\"exp1\"]);"; eval($eval1); $i1++; } //End Skill Grabs echo "<h2>".$user."</h2>"; echo "<table border='1' cellpadding='5'>"; echo "<tr>"; echo "<td><b>Skills</b></td>"; echo "<td><b>Rank</b></td>"; echo "<td><b>Level</b></td>"; echo "<td><b>XP</b></td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Overall</b></td>"; echo "<td>".$overall[0]."</td>"; echo "<td>".$overall[1]."</td>"; echo "<td>".$overall[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Attack</b></td>"; echo "<td>".$attack[0]."</td>"; echo "<td>".$attack[1]."</td>"; echo "<td>".$attack[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Defence</b></td>"; echo "<td>".$defence[0]."</td>"; echo "<td>".$defence[1]."</td>"; echo "<td>".$defence[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Strength</b></td>"; echo "<td>".$strength[0]."</td>"; echo "<td>".$strength[1]."</td>"; echo "<td>".$strength[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Constitution</b></td>"; echo "<td>".$hitpoints[0]."</td>"; echo "<td>".$hitpoints[1]."</td>"; echo "<td>".$hitpoints[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Ranged</b></td>"; echo "<td>".$ranged[0]."</td>"; echo "<td>".$ranged[1]."</td>"; echo "<td>".$ranged[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Prayer</b></td>"; echo "<td>".$prayer[0]."</td>"; echo "<td>".$prayer[1]."</td>"; echo "<td>".$prayer[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Magic</b></td>"; echo "<td>".$magic[0]."</td>"; echo "<td>".$magic[1]."</td>"; echo "<td>".$magic[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Cooking</b></td>"; echo "<td>".$cooking[0]."</td>"; echo "<td>".$cooking[1]."</td>"; echo "<td>".$cooking[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Woodcutting</b></td>"; echo "<td>".$woodcutting[0]."</td>"; echo "<td>".$woodcutting[1]."</td>"; echo "<td>".$woodcutting[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Fletching</b></td>"; echo "<td>".$fletching[0]."</td>"; echo "<td>".$fletching[1]."</td>"; echo "<td>".$fletching[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Fishing</b></td>"; echo "<td>".$fishing[0]."</td>"; echo "<td>".$fishing[1]."</td>"; echo "<td>".$fishing[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Firemaking</b></td>"; echo "<td>".$firemaking[0]."</td>"; echo "<td>".$firemaking[1]."</td>"; echo "<td>".$firemaking[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Crafting</b></td>"; echo "<td>".$crafting[0]."</td>"; echo "<td>".$crafting[1]."</td>"; echo "<td>".$crafting[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Smithing</b></td>"; echo "<td>".$smithing[0]."</td>"; echo "<td>".$smithing[1]."</td>"; echo "<td>".$smithing[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Mining</b></td>"; echo "<td>".$mining[0]."</td>"; echo "<td>".$mining[1]."</td>"; echo "<td>".$mining[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Herblore</b></td>"; echo "<td>".$herblore[0]."</td>"; echo "<td>".$herblore[1]."</td>"; echo "<td>".$herblore[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Agility</b></td>"; echo "<td>".$agility[0]."</td>"; echo "<td>".$agility[1]."</td>"; echo "<td>".$agility[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Thieving</b></td>"; echo "<td>".$thieving[0]."</td>"; echo "<td>".$thieving[1]."</td>"; echo "<td>".$thieving[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Slayer</b></td>"; echo "<td>".$slayer[0]."</td>"; echo "<td>".$slayer[1]."</td>"; echo "<td>".$slayer[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Farming</b></td>"; echo "<td>".$farming[0]."</td>"; echo "<td>".$farming[1]."</td>"; echo "<td>".$farming[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Runecrafting</b></td>"; echo "<td>".$runecraft[0]."</td>"; echo "<td>".$runecraft[1]."</td>"; echo "<td>".$runecraft[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Hunter</b></td>"; echo "<td>".$hunter[0]."</td>"; echo "<td>".$hunter[1]."</td>"; echo "<td>".$hunter[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Construction</b></td>"; echo "<td>".$construction[0]."</td>"; echo "<td>".$construction[1]."</td>"; echo "<td>".$construction[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Summoning</b></td>"; echo "<td>".$summoning[0]."</td>"; echo "<td>".$summoning[1]."</td>"; echo "<td>".$summoning[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Dungeoneering</b></td>"; echo "<td>".$dungeoneering[0]."</td>"; echo "<td>".$dungeoneering[1]."</td>"; echo "<td>".$dungeoneering[2]."</td>"; echo "</tr>"; echo "</table>"; echo "<h2>".$user1."</h2>"; echo "<table border=1 cellpadding=5>"; echo "<tr>"; echo "<td><b>Dungeoneering</b></td>"; echo "<td>".$dungeoneering1[0]."</td>"; echo "<td>".$dungeoneering1[1]."</td>"; echo "<td>".$dungeoneering1[2]."</td>"; echo "</tr>"; echo "</table>"; What is wrong with this code? Currently I am using this very popular code to get all the football scores: Code: [Select] $title = $params->get('title'); $fontc = $params->get('fontc'); $fonts = $params->get('fonts'); //this array contains sports and their URLs $sports = array( "NFL" => "http://sports.espn.go.com/nfl/bottomline/scores"); $results = array(); foreach ( $sports as $sport => $url ) { //get the page pointed to by $url $page = file_get_contents($url); //grab all variables out of the page preg_match_all("/&([^=]+)=([^&]+)/", urldecode($page), $foo); //loop through all the variables on the page foreach ( $foo[1] as $key => $value ) { //debug output, you can delete this next line //echo "{$value} = {$foo[2][$key]}\t<br />\n"; //this chain of IF/elseif statements is used to determine which pattern to use //to strip out the correct data, since each sport seems to have its own format //for the variables you'd "want" if ( $sport == "NFL" && preg_match("/s_left\d+/", $value) ) { $results[$sport][] = $foo[2][$key]; } } } //calculate the sport with the most number of rows $limit = 0; foreach ( $results as $countMe ) { $limit = max($limit, count($countMe)); } //spit out the table with the right headers echo "<td><b> $title </b></td><br><BR>"; "<table border=4 cellpadding=10><tr><th>" . implode("</th><th>", array_keys($sports)). "</th></tr>" ; //loop until you reach the max number of rows, printing out all the table rows you want for ( $p = 0; $p < $limit; $p++ ) { foreach ( array_keys($sports) as $sport );{ $change = str_replace('^','<font color=green><b>W</b> </font>' ,$results[$sport][$p]); $final = str_replace('(FINAL)','<font color=red>(FINAL)', $change); echo "<td><font color=$fonts size=$fontc><b>$final</b></font></td><br>"; } echo "</tr>"; } //kill the table echo "</table>"; and it works fantastically well however.... I'd only like to get certain data say like the Cowboys game info and nothing more... NOT too sure how to do this, I'm just not really sure how to read the page, grab only that data. Help would be greatly appreciated! Thank you. I think this belongs here, but my $_POST['gender'] won't grab the gender that was submitted through a form. I am using AJAX so the page doesn't have to reload so it can go in a smooth transition, but the AJAX is grabbing the value perfectly fine. I have a feeling the $_POST isn't grabbing the value because the page isn't reloading.. but I don't want to reload it. These codes are all on the same page. Here is my Javascript: Code: [Select] <script> function chooseGender() { var gender = $('input[name=gender]:checked', '#submitgender').val(); if(gender) { $.ajax( { type: "POST", url: window.location.pathname, data: gender, success: function() { alert("You have chosen to be a " + gender); //It's grabbing it perfectly fine! $("#submitgender").hide(); //It hides the gender table so they can't choose a gender since they already have chosen one. $("#rest").fadeIn(); //Shows the other table that's labeled "rest" as it's ID so they can choose what base, eyes, etc for that specific gender they've chosen. } }); } else { alert('Select a gender.'); } } $(function tabs() { $( "#tabs" ).tabs(); }); </script> But here is the PHP inside the #rest table: Code: [Select] <?php $gender = $_POST['gender']; $sql = "SELECT * FROM habases WHERE gender='".$gender."'"; $result = mysqli_query($cxn, $sql) or die(mysqli_error($cxn)); print_r($sql); while ($row = mysqli_fetch_assoc($result)) { $baseimage = $row['image']; $baseskin = $row['skin']; echo "<img src=\"http://www.elvonica.com/".$baseimage."\" value=\"".$baseskin."\">"; } ?> And this is what I'm getting for the print_r: Quote SELECT * FROM habases WHERE gender='' I am trying to have a search bar and this is the search results page. However when they search they have the option to type in anything and it will search the entire directory for what ever they type in so if they type in "Dog" I want dog to be searched for in the database under title and author this is the code I have now...can anyone help me?? Code: [Select] // Build SQL Query $query = "select * from videos where title like \"%$trimmed%\" order by id DESC"; // EDIT HERE and specify your table and field names for the SQL query Php Whizzes!
Need to grab geo ip. Why these 2 show data differently ? http://www.geoplugin.net/json.gp?ip=19.117.63.253 http://www.geoplugin.net/php.gp?ip=19.117.63.253 Which one you like ? I like 1st one.
Anyway, is this code any good ? Will it misfire ?
<?php //https://stackoverflow.com/questions/12553160/getting-visitors-country-from-their-ip function ip_info($ip = NULL, $purpose = "location", $deep_detect = TRUE) { $output = NULL; if (filter_var($ip, FILTER_VALIDATE_IP) === FALSE) { $ip = $_SERVER["REMOTE_ADDR"]; if ($deep_detect) { if (filter_var(@$_SERVER['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP)) $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; if (filter_var(@$_SERVER['HTTP_CLIENT_IP'], FILTER_VALIDATE_IP)) $ip = $_SERVER['HTTP_CLIENT_IP']; } } $purpose = str_replace(array("name", "\n", "\t", " ", "-", "_"), NULL, strtolower(trim($purpose))); $support = array("country", "countrycode", "state", "region", "city", "location", "address"); $continents = array( "AF" => "Africa", "AN" => "Antarctica", "AS" => "Asia", "EU" => "Europe", "OC" => "Australia (Oceania)", "NA" => "North America", "SA" => "South America" ); if (filter_var($ip, FILTER_VALIDATE_IP) && in_array($purpose, $support)) { $ipdat = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=" . $ip)); if (@strlen(trim($ipdat->geoplugin_countryCode)) == 2) { switch ($purpose) { case "location": $output = array( "city" => @$ipdat->geoplugin_city, "state" => @$ipdat->geoplugin_regionName, "country" => @$ipdat->geoplugin_countryName, "country_code" => @$ipdat->geoplugin_countryCode, "continent" => @$continents[strtoupper($ipdat->geoplugin_continentCode)], "continent_code" => @$ipdat->geoplugin_continentCode ); break; case "address": $address = array($ipdat->geoplugin_countryName); if (@strlen($ipdat->geoplugin_regionName) >= 1) $address[] = $ipdat->geoplugin_regionName; if (@strlen($ipdat->geoplugin_city) >= 1) $address[] = $ipdat->geoplugin_city; $output = implode(", ", array_reverse($address)); break; case "city": $output = @$ipdat->geoplugin_city; break; case "state": $output = @$ipdat->geoplugin_regionName; break; case "region": $output = @$ipdat->geoplugin_regionName; break; case "country": $output = @$ipdat->geoplugin_countryName; break; case "countrycode": $output = @$ipdat->geoplugin_countryCode; break; } } } return $output; } echo ip_info("119.30.32.215", "Country"); ?><br><?php echo ip_info("119.30.32.215", "Country Code"); ?><br><?php echo ip_info("119.30.32.215", "State"); ?><br><?php echo ip_info("119.30.32.215", "City"); ?><br><?php echo ip_info("119.30.32.215", "Address"); ?><br><?php print_r(ip_info("119.30.32.215", "Location")); // Array ( [city] => Menlo Park [state] => California [country] => United States [country_code] => US [continent] => North America [continent_code] => NA ) ?>
What you say ? Lemme see your sample code.
Thanks! Hi, guys. I want to present different ads to visitors in different countries. For example, if a visitor is in Australia, I want him/her to see a different ad from, say, a visitor from the UK. Can this kind of thing be done with PHP? If so, will installing such a code slow down my site? Any help will be appreciated very much. Hi All, not sure if this is a php Q but maybe someone has experience with this. I use a form for people to add an item to the bulletin board. Sometimes the loading of the page takes very long and people think it didn't work so they click reload and post the item twice. I thought of adding a loading.gif so people know they have to wait. Anyone know how and where to put that in? Code: [Select] <?PHP if(isset($_POST['submit'])) { if ($_POST['type']<>"") { $poster_id = $_SESSION['id']; $ID=$_GET['ID']; $short=$_POST['short']; $location=$_POST['location']; if(isset($_POST['type'])) { $type=$_POST['type']; } $starthour=$_POST['starthour']; $startmin=$_POST['startmin']; $endhour=$_POST['endhour']; $endmin=$_POST['endmin']; $reminders=$_POST['reminders']; $reminders=addslashes($reminders); if(isset($_POST['view'])) { $view=$_POST['view']; } if(isset($_POST['val'])) { $val=$_POST['val']; } $sql = mysql_query("SELECT * from bl_calender where dateclass='$ID' AND viewable='1'"); $numrows = mysql_num_rows($sql); // if the event exists then we want to edit it if ($numrows > 0){ // only the owner can edit an event while($row = mysql_fetch_array($sql)){ if($row['poster_id'] == $logOptions_id || $account_type == 'c' ){ $editcal="update bl_calender set datecotent='$reminders', location='$location', type='$type', starthour='$starthour', startmin='$startmin', endhour='$endhour', endmin='$endmin', short='$short', viewable='$view' where dateclass='$ID'"; mysql_query($editcal) or die("Could not edit calendar"); $msgToUser = '<br /><br /><font color="#FF0000">Your event has been updated. Close this window.</font><p></p>'; include_once 'msgToUser2.php'; } else { // you are not the owner $msgToUser = '<br /><br /><font color="#FF0000">Sorry but only the owner can change the event details.<br> Close this window.</font><p></p>'; include_once 'msgToUser2.php'; } } } else { // it's a new event we want to add $createevent="Insert into bl_calender (poster_id, dateclass, starthour, startmin, endhour, endmin, location, type, short, datecotent, viewable ) values ('$poster_id', '$ID', '$starthour', '$startmin', '$endhour', '$endmin', '$location', '$type', '$short', '$reminders', '1')"; mysql_query($createevent) or die(mysql_error()); $sql2 = mysql_query("SELECT * FROM myMembers WHERE notification_calendar='1'"); // query the members who want an email $numrows = mysql_num_rows($sql2); if ($numrows > 0){ while($row = mysql_fetch_array($sql2)){ if($row['email'] =="") { $to = $row['email_work']; } else { $to = $row['email']; } $your_firstname = $row['firstname']; $your_lastname = $row['lastname']; // send an email to everyone who wants it $webmaster = "KAI-DEFAT@minbuza.nl"; $headers = "From: MAAC Webmaster<$webmaster>"; $subject = "A new message has been posted in the MAAC Calendar."; $message = "Hello $your_firstname $your_lastname, a new event has been posted in the MAAC Calendar.\n"; $message .= "Goto the MAAC website to get the details.\n"; $message .= "Click here to view the Calendar $dyn_www/Web_Intersect/calen.php\n"; // send email mail($to, $subject, $message, $headers); } } } $msgToUser = '<br /><br /><font color="#FF0000">Your event has been created, Close this window.</font><p></p>'; include_once 'msgToUser2.php'; } ?> |