shalli
Members-
Posts
30 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
shalli's Achievements
Member (2/5)
0
Reputation
-
Hi teynon, ZulfadlyAshBurn Thanks for your reply it seems it was an error with my server (according to hosting techie) - it seems to be working now Not sure what happened but thanks for your response!!!
-
Hi There I have a simple cms system that I have built but for some reason the login script wont let me login to the cms. Strange thing is the script seems to works on the original database but when I changed the details to a new db it doesnt work. I have made the necessary changes for the connecting to the db etc but it just wont let me login. Can anyone help The url is drmonlinemarketing.com/cms2/loginadmin.php try login with username demo password test thanks shalli
-
Hi There I used this for a site of mine http://www.evolt.org/node/60384 Hope this helps
-
Hi there Just wanted to know what everyone here would recommend to a newbie in php about adding php code to mysql database and then retreiving it I would like to create a is a php template site that allows user to choose the template they like and once the user selects the template it takes the user to a page that shows template code. The page use php variables to display the code from the database. as an example it like dreamweaver which allow you to choose from a selection of templates when creating a website Hope this make sense thanks for you time shalli
-
Thanks mikosiko For all your help!!
-
thanks for your response Crayon Violent Yes it seems to do nothing I entered the following echo to check that I was passing the correct variables echo "$ProductName <br> $ProductText <br> $ProductImage <br> $ProductPrice"; Basically what the code does is display a form with the data from the database and you edit that data in the form and when you click submit it should update the database I was using this tutorial to help me create this functionality http://www.maaking.com/index.php?loadpage=tutorials hope this help
-
Hi There I am trying to create a page that edit mysql database from a php page. I can get the edit page to show the orginal information but it wont update the data in the mysql database. I am sure I have entered everything right. If anyone could help with this I would greatly appreciated <?php include("dbconnect.php"); if(isset($_POST['submit'])) { // Set global variables to easier names // and prevent sql injection and apostrophe to break the db. $ProductName = mysql_escape_string($_POST['ProductName']); $ProductText = mysql_escape_string($_POST['ProductText']); $ProductImage = mysql_escape_string($_POST['ProductImage']); $ProductPrice = mysql_escape_string($_POST['ProductPrice']); $result = mysql_query("UPDATE Product SET ProductName='$ProductName', ProductText='$ProductText', ProductImage='$ProductImage', ProductPrice='$ProductPrice' WHERE ID='$ID' ",$dbconnect); echo "<b>Thank you! Product UPDATED Successfully!<br>You'll be redirected to View Page after (2) Seconds"; echo "<meta http-equiv=Refresh content=2;url=view.php>"; echo "$ProductName <br> $ProductText <br> $ProductImage <br> $ProductPrice"; } elseif(isset($_GET['ID'])) { $result = mysql_query("SELECT * FROM Product WHERE ID='$_GET[iD]' ",$dbconnect); while($myrow = mysql_fetch_assoc($result)) { $ProductName = $myrow["ProductName"]; $ProductText= $myrow["ProductText"]; $ProductImage = $myrow["ProductImage"]; $ProductPrice = $myrow["ProductPrice"]; ?> <br> <h3>::Edit Product</h3> <form method="post" action="<?php echo $PHP_SELF ?>"> <input type="hidden" name="ID" value="<? echo $myrow['ID']?>"> Product Name: <input name="ProductName" size="40" maxlength="255" value="<? echo $ProductName; ?>"><br> Product Text: <textarea name="ProductText" rows="7" cols="30"><? echo $ProductText; ?></textarea><br> Product Image: <textarea name="ProductImage" rows="7" cols="30"><? echo $ProductImage; ?></textarea><br> Product Price: <textarea name="ProductPrice" rows="7" cols="30"><? echo $ProductPrice; ?></textarea><br> <input type="submit" name="submit" value="Update Product"> </form> <? }//end of while loop }//end else ?>
-
Hi there Been trying to figure this out but how do you limit charachters on a mysql query <?php //$qry="select * from news where status=1 order by date_Added DESC"; $qry="select * from wp_posts order by post_date DESC"; $sql=mysql_query($qry,$connBlog); //$news=mysql_fetch_array(); while($news=mysql_fetch_array($sql)){ $arr[]=$news['post_title', 0, 25];?> js_ar.push("<?=$news['post_title']?>"); <?php }?> thanks shalli
-
hi Teddykiller Thanks for your response Here is my code /** * The curl class */ class curl { /** * COnstructor */ function curl() { } function init_curl($ch,$url,$postfields=null,$follow=null,$cookie=null,$referer=null) { // Set url curl_setopt($ch, CURLOPT_URL, $url); // Enable Post if($postfields) { curl_setopt ($ch, CURLOPT_POST, 1); curl_setopt ($ch, CURLOPT_POSTFIELDS, $postfields); } if($follow) { curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1 ); } if($referer) { curl_setopt($ch, CURLOPT_REFERER, $referer); } //Enable SSL curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)'); //Return results as string curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); return $ch; } // end function /* Grabs a page */ function get_page($options) { //Set options foreach($options AS $key=>$value) { $$key = $value; } $ch = curl_init(); $ch = $this->init_curl($ch,$url,$postfields,$follow,$cookie); $page = curl_exec($ch); curl_close($ch); return $page; } } // end class /** * A simple wrapper for db functions * */ class db_custom { /** * Constructor * * A simple wrapper for database functions * */ function db_custom() { // database configuration $host = "localhost"; $user = "xxxx"; $pass = "xxxx"; $db = "xxxx"; // open database connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); } ############################################### ## Updates an array of fields and values ## and reurn the resulting ID ############################################### function quick_update($database,$fields,$values,$wherearray) { //Variables $num_array = count($values); //Format NULL $values = str_replace("'NULL'","NULL",$values); //Write query $query = "UPDATE `$database` SET "; foreach ($fields AS $key=>$value) { $count++; $query .= " $fields[$key] = '$values[$key]'"; if ($count <> $num_array) { $query .= ","; } } //Create where foreach ($wherearray AS $key=>$value) { $counterv++; $query_chk .= "$key = '" . trim($value) . "'"; if ($counterv != count($wherearray)) { $query_chk .= " AND "; } } $query .= " WHERE $query_chk"; $query = str_replace("'`","",$query); $query = str_replace("`'","",$query); $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error()); $rows = mysql_affected_rows(); return $rows; } ###################################################### # Execute row # runs query and gets row back ###################################################### function executeRow($query__ER,$type=null) { $result__ER = mysql_query($query__ER) or die ("Error in query: $query__ER. " . mysql_error()); if($result__ER != 1) { if($type!="array") { $row__ER = mysql_fetch_object($result__ER); } else { $row__ER = mysql_fetch_assoc($result__ER); } return $row__ER; } } ###################################################### # Connects to the database and returns the # results in an array ###################################################### function executeQuery($query,$func=null,$type="") { //Get the table name from the query preg_match("/SELECT(.*)FROM( )([A-z_]+)/i",$query,$matches); $table_name = $matches[3]; $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error()); $rows = mysql_num_rows($result); $columns = mysql_fetch_assoc($result); if ($rows > 0) { // Only proceed if we have a result mysql_data_seek($result,0); while ($row=mysql_fetch_array($result)) { foreach ($columns As $key=>$value) { //Run any extra functions that have been sent over if(is_array($func)) { foreach ($func AS $Fkey=>$Fvalue) { $row[$key] = $this->$Fvalue($row[$key],$key,$table_name); } // end FE } // end IF if($type == "object") { //echo $key . " " . $row[$key] . "\n"; $tmp->$key = $row[$key]; } else { $tmp[$key] = $row[$key]; } }// end for each $results[] = $tmp; unset($tmp); } //end while $final_result['result'] = $results; $final_result['rows'] = mysql_num_rows($result); } else { $final_result['rows'] = 0; }// end if return $final_result; } // end function } /** * A postcode finder class * */ class postcode_finder { /** * Constructor * */ function postcode_finder($array) { if(is_array($array)) { foreach($array AS $key=>$value) { $this->$key = $value; } } //DO stuff } /** * Setup database tables and insert lat longs * */ function setup() { $this->create_store_table(); $this->insert_example_stores(); $this->update_lat_lngs(); } /** * Makes an example store table * */ function create_store_table() { //Create table $query = "CREATE TABLE IF NOT EXISTS `store` ( `id` int(10) NOT NULL auto_increment, `name` varchar(75) NOT NULL default '', `address` text NOT NULL, `postcode` varchar(10) NOT NULL default '', `lat` double NOT NULL default '0', `lng` double NOT NULL default '0', `domain` varchar(10) NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE=MyISAM"; $this->db->executeRow($query); } /** * Insert some example stores * */ function insert_example_stores() { //for($i=0;$i<1000;$i++) { //$query = " //INSERT INTO `store` (`name` , `address` , `postcode`, `domain`) //VALUES ( //'Waterloo Station', 'Lambeth, London', 'SE1', 'co.uk' //), ( //'Gatwick Airport ', 'South Terminal, Gatwick', 'RH6', 'co.uk' //), ( //'Edinburgh Waverley Railway Station ', 'Network Rail, Room 255, North Block, Edinburgh', 'EH1 1BB', 'co.uk' //), ( //'Beverly Hills', 'California', '90210', 'com' //), ( //'Penn Station ', '17 W 32nd St New York', '10001', 'com' //), ( //'La Sagrada Familia', 'Barcelona', '08013', 'es' //), ( //'FC Bayern Munchen', 'Sabener Str. 51, Munchen, Germany ', '81547', 'de' //) //"; //$this->db->executeRow($query); //} } /** * Update lat lngs * */ function update_lat_lngs() { //Get the list of stores $query = "SELECT * FROM store WHERE `lat` = '' LIMIT 0,10"; $stores = $this->db->executeQuery($query); $stores = $stores['result']; //Run through stores and get lat / lng foreach($stores AS $store) { $latlng = $this->get_lat_long($store['postcode'],$store['telephone'],$store['fax'],$store['managername']); //Update store with its lat lng $this->db->quick_update("store", array('lat','lng'), array($latlng['lat'],$latlng['lng']), array('id'=>$store['id']) ); } } /** * Returns a lat / long of a given postcode * */ function get_lat_long($postcode,$domain=null) { if(!$domain) { $domain = "co.uk"; } $url = "http://maps.google." . $domain . "/maps/geo?q=" . urlencode($postcode) . "&output=json&key=ABQIAAAAWjc0ZH2RENLxziofASg9ABQH987j_SlqISv1l93HS7ksPkvN9xRAXjKLSj-Yj2Xw7I6gP3RHQb4UQg"; $json = $this->curl->get_page(array("url"=>$url)); $store_data = json_decode(str_replace(""","\"",htmlentities($json))); //Take care of accents $lng = $store_data->Placemark[0]->Point->coordinates[0]; $lat = $store_data->Placemark[0]->Point->coordinates[1]; //Return if($lng && $lat) { return array('lat'=>$lat, 'lng'=>$lng ); } else { return false; } } /** * Get a list of our stores, sorted by distance to this postcode * */ function get_stores_list($postcode) { //If it's a UK postcode then format correctly $postcode = $this->checkPostcode($postcode); $latlng = $this->get_lat_long($postcode); if(!$latlng) { //Unrecognised postcode return false; } $latitude = $latlng['lat']; $longitude = $latlng['lng']; // print_r($latlng); $query = "SELECT *, (((acos(sin((".$latitude."*pi()/180)) * sin((`lat`*pi()/180)) +cos((".$latitude."*pi()/180)) * cos((`lat`*pi()/180)) * cos(((".$longitude."- `lng`)*pi()/180))))*180/pi())*60*1.1515) as distance FROM `store` ORDER BY distance ASC LIMIT 1 "; $stores = $this->db->executeQuery($query); $stores = $stores['result']; return $stores; } /** * Checks whether supplied postcode is a valid UK postcode */ function checkPostcode($toCheck) { $orig = $toCheck; // Permitted letters depend upon their position in the postcode. $alpha1 = "[abcdefghijklmnoprstuwyz]"; // Character 1 $alpha2 = "[abcdefghklmnopqrstuvwxy]"; // Character 2 $alpha3 = "[abcdefghjkstuw]"; // Character 3 $alpha4 = "[abehmnprvwxy]"; // Character 4 $alpha5 = "[abdefghjlnpqrstuwxyz]"; // Character 5 // Expression for postcodes: AN NAA, ANN NAA, AAN NAA, and AANN NAA $pcexp[0] = '^('.$alpha1.'{1}'.$alpha2.'{0,1}[0-9]{1,2})([0-9]{1}'.$alpha5.'{2})$'; // Expression for postcodes: ANA NAA $pcexp[1] = '^('.$alpha1.'{1}[0-9]{1}'.$alpha3.'{1})([0-9]{1}'.$alpha5.'{2})$'; // Expression for postcodes: AANA NAA $pcexp[2] = '^('.$alpha1.'{1}'.$alpha2.'[0-9]{1}'.$alpha4.')([0-9]{1}'.$alpha5.'{2})$'; // Exception for the special postcode GIR 0AA $pcexp[3] = '^(gir)(0aa)$'; // Standard BFPO numbers $pcexp[4] = '^(bfpo)([0-9]{1,4})$'; // c/o BFPO numbers $pcexp[5] = '^(bfpo)(c\/o[0-9]{1,3})$'; // Load up the string to check, converting into lowercase and removing spaces $postcode = strtolower($toCheck); $postcode = str_replace (' ', '', $postcode); // Assume we are not going to find a valid postcode $valid = false; // Check the string against the six types of postcodes foreach ($pcexp as $regexp) { if (ereg($regexp,$postcode, $matches)) { // Load new postcode back into the form element $toCheck = strtoupper ($matches[1] . ' ' . $matches [2]); // Take account of the special BFPO c/o format $toCheck = ereg_replace ('C\/O', 'c/o ', $toCheck); // Remember that we have found that the code is valid and break from loop $valid = true; break; } } // Return with the reformatted valid postcode in uppercase if the postcode was // valid if ($valid){ return $toCheck; } else { $this->non_standard_postcode = true; return $orig; }; } } //If we have a post if($_GET['postcode']) { //Start database class $db = new db_custom(); $curl = new curl(); $finder = new postcode_finder(array('db'=>$db, 'curl'=>$curl)); $stores = $finder->get_stores_list($_GET['postcode']); } if($_GET['fill']) { $db = new db_custom(); $curl = new curl(); $finder = new postcode_finder(array('db'=>$db, 'curl'=>$curl)); $finder->setup(); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>L4L Postcode Finder</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <!-- rounded corner css --> <link rel="stylesheet" type="text/css" href="http://www.legal4landlords.com/css/niftyCorners.css" /> <link type="text/css" rel="stylesheet" href="http://www.legal4landlords.com/css/postcodestyle.css" /> <!-- Aciddrop Theme Created by Leon Chevalier @ Aciddrop (http://www.aciddrop.com/) --> </head> <body> <div id="" style="width:645px;margin:0 auto"> <div style="padding-top: 0pt; padding-bottom: 0pt;" class="roundedByNifty" id="content"><b style="background-color: rgb(223, 223, 223);" class="artop"><b style="border-color: rgb(204, 204, 204); background-color: rgb(138, 199, 239);" class="re1"></b><b style="border-color: rgb(204, 204, 204); background-color: rgb(138, 199, 239);" class="re2"></b><b style="border-color: rgb(204, 204, 204); background-color: rgb(138, 199, 239);" class="re3"></b><b style="border-color: rgb(204, 204, 204); background-color: rgb(138, 199, 239);" class="re4"></b></b> <div id="content_inner"> <div class="posts_content"> <div id="post_wrapper"> <br> <br> <form action="" method="get"> <fieldset> <legend>Enter your postcode</legend> <input type="text" name="postcode" value="<?= $_GET['postcode'] ?>"> <input type="submit" value="GO!"> </fieldset> </form> <? if ($_GET['fill']) { ?> <h2 style="background-color:padding:2px">Database filled</h2> <? } ?> <? if ($_GET['postcode']) { ?> <? if ($stores) { ?> <h2 style="background-color:padding:2px">The following stores were found near to you</h2> <? foreach($stores AS $store) { ?> <p> <h3><span id="storenameheading">Store Name:</span><span id="storename"><?= $store['name'] ?></span></h3> <span id="storeaddressheading">Store Address:</span><span id="storeaddress"><?= $store['address'] ?></span><br> <span id="storepostcodeheading">Store Postcode:</span><span id="storepostcode"><?= $store['postcode'] ?></span><br> <span id="storetelephoneheading">Store Telephone:</span><span id="storetelephone"><?= $store['telephone'] ?></span><br> <span id="storefaxheading">Store Fax:</span><span id="storefax"><?= $store['fax'] ?></span><br> <span id="storemanagernameheading">Store Manager Name:</span><span id="storemanangername"><?= $store['managername'] ?></span><br> <span style="background-color:#FFFFCC"><?= number_format($store['distance'],2) ?></span> miles from you </p> <? } ?> <? } else { ?> <h2 style="background-color:padding:2px">That postcode was not recognised</h2> <? } ?> <? } ?> </div> </div> <div class="posts_content"> </div> </div> <b style="background-color: rgb(223, 223, 223);" class="artop"><b style="border-color: rgb(204, 204, 204); background-color: rgb(138, 199, 239);" class="re4"></b><b style="border-color: rgb(204, 204, 204); background-color: rgb(138, 199, 239);" class="re3"></b><b style="border-color: rgb(204, 204, 204); background-color: rgb(138, 199, 239);" class="re2"></b><b style="border-color: rgb(204, 204, 204); background-color: rgb(138, 199, 239);" class="re1"></b></b></div> </div> <div class="spacer_small"></div> </div> </body> </html>
-
Hi thanks for your reply. I need it to store details of a customer and there score on a particlar application and info on which company they work for etc. Hope this makes sense
-
Hi I have created a store locator that displays the nearest store nearest to the postcode a user types in. But what I would like to add is a functionality that if a postcode is typed that aint near say se (london) yo (york) s(sheffield) then its redirects to headoffice. Is that possible. Any help much appreciated
-
Yeah All I seem to find are content management tools and some open source options but no tutorials
-
Hi there Does anyone now any good tutorials on how to create a contact management tools from scratch. Any advise will be much appreciated thanks
-
Thanks guys Works perfectly
-
Hi there My clients wants me to copy the email that is sent to the customer to his sales department and the webmaster. But all I seem to get is a blank email with the subject line no message. I have tried every solution available online. But It doesnt seem to work Here is my code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Send Quote to SF</title> </head> <body> <?php // Define $myusername and $mypassword $buildingsum=strip_tags($_POST['buildingsum']); $contentsum=strip_tags($_POST['contentsum']); $rentguarantee12=strip_tags($_POST['rentguarantee12']); $rentguarantee6=strip_tags($_POST['rentguarantee6']); $result=strip_tags($_POST['result']); $name=strip_tags($_POST['name']); $address=strip_tags($_POST['address']); $postcode=strip_tags($_POST['postcode']); $email=strip_tags($_POST['email']); $contactno=strip_tags($_POST['contact']); $properties=strip_tags($_POST['properties']); $buildvalue=strip_tags($_POST['value']); $claims=strip_tags($_POST['claims']); $flood=strip_tags($_POST['flood']); $renewaldate=strip_tags($_POST['rendate']); $premiumexpected=strip_tags($_POST['premium']); // mail insurance confirmation to shalli and send the customer an email confirmation $buildingsum=strip_tags($_POST['buildingsum']); $contentsum=strip_tags($_POST['contentsum']); $rentguarantee12=strip_tags($_POST['rentguarantee12']); $rentguarantee6=strip_tags($_POST['rentguarantee6']); $result=strip_tags($_POST['result']); $name=strip_tags($_POST['name']); $address==strip_tags($_POST['address']); $postcode==strip_tags($_POST['postcode']); $email=strip_tags($_POST['email']); $contactno=strip_tags($_POST['contact']); $properties=strip_tags($_POST['properties']); $buildvalue=strip_tags($_POST['value']); $claims=strip_tags($_POST['claims']); $flood=strip_tags($_POST['flood']); $renewaldate=strip_tags($_POST['rendate']); $premiumexpected=strip_tags($_POST['premium']); $subject="Your Legal4Landlords Quick Insurance Quote"; $body = "Building Sum Insured: $buildingsum Contents Sum Insured: $contentsum, Rent Guarantee 12: $rentguarantee12, Rent Guarantee 6: $rentguarantee6, Premium Quoted: $result, Name: $name, Address: $address, PostCode: $postcode, Email: $email, Contact: $contactno, No of Properties: $properties, Building Value: $buildvalue, Have you made any claims: $claims, Has your property been flooded: $flood, Renewal Date: $renewaldate, Premium Expected: $premiumexpected"; echo "Thank Your for sumitting your insurance quote to Legal 4 Landlords Insurance Team. We will respond shortly to you shortly!" ; mail($email, $subject, $body); //These are the variables for the email $sendto = $_POST['email']; // this is the email address collected form the form $ccto = "test@legal4landlords.com"; //copied sales into email $bcc = "webmaster@legal4landlords.com"; //blind copy webmaster into email $subject = "email confirmation for landlord insurance"; // Subject // This is the function to send the email to webmaster and sales $message = "Building Sum Insured: $buildingsum Contents Sum Insured: $contentsum, Rent Guarantee 12: $rentguarantee12, Rent Guarantee 6: $rentguarantee6, Premium Quoted: $result, Name: $name, Address: $address, PostCode: $postcode, Email: $email, Contact: $contactno, No of Properties: $properties, Building Value: $buildvalue, Have you made any claims: $claims, Has your property been flooded: $flood, Renewal Date: $renewaldate, Premium Expected: $premiumexpected"; mail($ccto, $bcc, $subject, $message); ?> <script language=javascript> setTimeout("location.href='http://www.legal4landlords.com/thanks/'", [10]); </script> </body> </html> Please help I am really confused :wtf: :'( :'( :'( :'(