PHP - How Do I Include A Resizing Script To My Existing Script?
I'm trying to use this script known as SimpleImage.php that can be found here <a href="http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php">link</a> I'm trying to include what is on the bottom of the page to my existing script can anyone help me I've tried several ways but its not working.
Code: [Select] <?php session_start(); error_reporting(E_ALL); ini_set('display_errors','On'); //error_reporting(E_ALL); // image upload folder $image_folder = 'images/classified/'; // fieldnames in form $all_file_fields = array('image1', 'image2' ,'image3', 'image4'); // allowed filetypes $file_types = array('jpg','gif','png'); // max filesize 5mb $max_size = 5000000; //echo'<pre>';print_r($_FILES);exit; $time = time(); $count = 1; foreach($all_file_fields as $fieldname){ if($_FILES[$fieldname]['name'] != ''){ $type = substr($_FILES[$fieldname]['name'], -3, 3); // check filetype if(in_array(strtolower($type), $file_types)){ //check filesize if($_FILES[$fieldname]['size']>$max_size){ $error = "File too big. Max filesize is ".$max_size." MB"; }else{ // new filename $filename = str_replace(' ','',$myusername).'_'.$time.'_'.$count.'.'.$type; // move/upload file $target_path = $image_folder.basename($filename); move_uploaded_file($_FILES[$fieldname]['tmp_name'], $target_path); //save array with filenames $images[$count] = $image_folder.$filename; $count = $count+1; }//end if }else{ $error = "Please use jpg, gif, png files"; }//end if }//end if }//end foreach if($error != ''){ echo $error; }else{ /* -------------------------------------------------------------------------------------------------- SAVE TO DATABASE ------------------------------------------------------------------------------------ -------------------------------------------------------------------------------------------------- */ ?> Similar TutorialsHello Everyone, I've successfully created a form script to check to make sure all my fields are filled out. However, I wanted to create an if statement to check and see if the email address is valid and it contains both and "@", "." symbols. If not then echo '' This is not a Valid email address " if its not correct. Could someone tell me the proper way to write this and incorporate this into my existing script below. Thank you all Again for your Help thanks mrjap1 Code: [Select] // Confirm All feild were filled out when submit button was pressed if($name && $email && $username && $password && $confirm_password) { // Confirm that the NAME that you used is NOT greater than 30 characters if(strlen($name)>24) { echo "<h2><center>YOUR NAME IS TOO LONG!!!!</center></h2><br>"; } // Confirm that the EMAIL that you used is NOT greater than 25 characters if(strlen($email)>25) { echo "<h2><center>YOUR EMAIL IS TOO LONG!!!!</center></h2><br>"; } // Confirm that the USERNAME that you used is NOT greater than 10 characters if(strlen($username)>10) { echo "<h2><center>YOUR USERNAME IS TOO LONG!!!!</center></h2><br>"; } else { // Confirm that the PASSWORD that you used MATCH & Between 6 and 15 characters if(strlen($password)>10 || strlen($password)<6) { echo "<h2><center>YOUR PASSWORD MUST BE BETWEEN 6 and 15 CHARACTERS!!!!</center></h2><br>"; } if($password == $confirm_password) { Hello All! I was hoping one of you phpFreaks could help me out I have the following code that produces links from a database. Certain sets of results have over 3000 links. I can currently set the amount of links to display per page but that's it. I would like to be able to truncate the links to all the pages using pagination. Any help would be greatly appreciated! Here is the code: <?php echo "Results<br><HR WIDTH=100% SIZE=1><br>"; mysql_connect("mysite.com", "mysite_mysite", "mysitepassword") or die(mysql_error()); mysql_select_db("user_database") or die(mysql_error()); if (isset($_GET['pagenum'])) { $pagenum = $_GET['pagenum']; } else { $pagenum = 1; } $rpg = $pagenum; $data = mysql_query("SELECT * FROM mydb WHERE mfg='golf'") or die(mysql_error()); $rows = mysql_num_rows($data); $page_rows = 80; $last = ceil($rows/$page_rows); if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; $data_p = mysql_query("SELECT * FROM mydb WHERE mfg='golf' $max") or die(mysql_error()); while($info = mysql_fetch_array( $data_p )) { $page=$info['link']; echo "<a href='$page' class='blue1'>". $info['title'] . "</a><br>"; } echo "<p>"; if ($pagenum > $last) {$pagenum=1;} else { echo "<HR WIDTH=100% SIZE=1><br>"; $pagenum = 1; while ($pagenum <= $last) { $next = $pagenum; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$next' class='g5'>$pagenum</a> "; $pagenum = $pagenum+1; } Echo "<br><br>Page $rpg of $last <br>"; } ?> Simple insertion of pagination would be GREAT! Thanks guys....
Hello! I found this code from github. https://github.com/gburtini/Learning-Library-for-PHP and I want to know if its possible to add variables to it and what changes needed to be done to the whole script. $xs and $ys I want replace them and add two more. The whole code is he <?php require_once 'function.php'; function ll_nn_predict($xs, $ys, $row, $k) { $distances = ll_nearestNeighbors($xs, $row); $distances = array_slice($distances, 0, $k); $predictions = array(); foreach($distances as $neighbor=>$distance) { $predictions[$ys[$neighbor]]++; } asort($predictions); return $predictions; } function ll_nearestNeighbors($xs, $row) { $testPoint = $xs[$row]; $distances = _ll_distances_to_point($xs, $testPoint); return $distances; } function _ll_distances_to_point($xs, $x) { $distances = array(); foreach($xs as $index=>$xi) { $distances[$index] = ll_euclidean_distance($xi, $x); } asort($distances); array_shift($distances); return $distances; } and the function.php that is required is this: <?php function ll_transpose($rows) { $columns = array(); for($i=0;$i<count($rows);$i++) { for($k = 0; $k<count($rows[$i]); $k++) { $columns[$k][$i] = $rows[$i][$k]; } } return $columns; } function ll_mean($array) { return array_sum($array)/($array); } function ll_variance($array) { $mean = ll_mean($array); $sum_difference = 0; $n = count($array); for($i=0; $i<$n; $i++) { $sum_difference += pow(($array[$i] - $mean),2); } $variance = $sum_difference / $n; return $variance; } function ll_euclidean_distance($a, $b) { if(count($a) != count($b)) return false; $distance = 0; for($i=0;$i<count($a);$i++) { $distance += pow($a[$i] - $b[$i], 2); } return sqrt($distance); } I just want to know where is the variables in those 2 scripts and add more as I'm not well versed in using PHP. Thank you! I'm trying to get my php form to send a simple auto responder to the persons email that submitted the form. Something like "Thanks we received your info". I don't know how to integrate that into my existing script. Below are the configurable parts of the php. The form works perfectly ... just want to add the auto respond function. Thanks! _________________________________________________ _________________________________________________ _____ <?php $d = date("m-d-y H:i:s"); /* ************* Begin Configuration ************* */ $relocate = "http://www.xxxxx.com/"; // insert your relocation url here $home = "http://www.xxxxx.com/"; $MOVE_TO_PATH = '/home/content/xxxxx/html/FileUpload/'; $PATH_TO_DIR = 'http://www.xxxxx.com/FileUpload/'; $sender_name = "Order"; $sender_email = "me@xxxxx.com"; $mailheaders = "Content-Type: text/plain; charset=us-ascii\nFrom: $sender_name <$sender_email>\nReply-To: <$sender_email>\nReturn-Path: <$sender_email>\nX-Mailer: PHP"; //$to = "me@xxxxx.com"; $to = "me@xxxxx.com"; $subject = "Order"; $success_block = "<p>Thank you for submitting your information. We will review your information and get back to you within a day or two.</p><br><br>"; /* ************* End Configuration ************* */ if ($send != "false") { mail($to, $subject, $msg, $mailheaders); // mail sent to admin header("Location: $relocate"); } ?> This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=315539.0 This topic has been moved to CSS Help. http://www.phpfreaks.com/forums/index.php?topic=315590.0 Trying to use an include() in a script to send an email, not working out. Basically I have a pretty drastic page I've formatted out and I want it to be shipped out in an email in that format. I thought it would be simple to get an include in a php code to email but the email works.. and doesn't have anything in it. I've tried with and without quotes, any help appreciated. Code: [Select] <html> <body> <? //change this to your email. $to = "me@me.com"; $from = "me@me.com"; $subject = "stuff"; $message="<?php include("another.php"); ?>" $headers = "From: $from\r\n"; $headers .= "Content-type: text/html\r\n"; //options to send to cc+bcc //$headers .= "Cc: [email]maa@p-i-s.cXom[/email]"; //$headers .= "Bcc: [email]email@maaking.cXom[/email]"; // now lets send the email. mail($to, $subject, $message, $headers); echo "Message has been sent....!"; ?> </html> </body> Hi I have previously posted this in the Jquery section but im not so sure its a Jquery issue now, so apoligies for the double post. I am having an issue with a rating system that works if i access the gamecards.php file through its absolute path (www..../...../gamecards.php) but will not work if i access it through a file that it is an include of (www..../reviews.php) Basicaly, when i click on the link through the include, the data is not sent to the DB and the data does not refresh. gamecards.php all works fine when its not as an include. Any ideas why? Gamecards.php is posted below Code: [Select] <!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=iso-8859-1" /> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(function() { $(".vote").click(function() { var id = $(this).attr("id"); var name = $(this).attr("name"); var dataString = 'id='+ id ; var parent = $(this); if(name=='up') { $(this).fadeIn(200).html('<img src="dot.gif" align="absmiddle">'); $.ajax({ type: "POST", url: "up_vote.php", data: dataString, cache: false, success: function(html) { parent.html(html); } }); } else { $(this).fadeIn(200).html('<img src="dot.gif" align="absmiddle">'); $.ajax({ type: "POST", url: "down_vote.php", data: dataString, cache: false, success: function(html) { parent.html(html); } }); } return false; }); }); </script> </head> <body> <?php include('config.php'); //get results from db if (isset($_GET['gameid']) && is_numeric($_GET['gameid'])) { $gameid = mysql_real_escape_string($_GET['gameid']); $sql = "SELECT * FROM Games WHERE gameid = $gameid"; $res = mysql_query($sql); $data = mysql_fetch_assoc($res); // However you'd like to format the html to output $title=$data['gametitle']; $cover=$data['cover']; $gameid=$data['gameid']; $info=$data['info']; $genre=$data['genre']; $rdate=$data['releasedate']; $format=$data['format']; $dir1="coverart"; $reviews="Enter Reviews Here"; date("d/m/y",$rdate); echo "<div id='cardcontainer_full'> <div id='coverart'><img src='$dir1/{$cover}' width='100' height='140'><br></div> <div id='gametitle'>$title</div> <div id='features'>Gen $genre<br><br> Release Date: $rdate<br><br> Available for: $format<br><br> </div> <div id='gameinfo'><div style='font-weight:bold'>Summary</div><br>$info <p><div style='font-weight:bold'>Reviews</div><p>$reviews </div> </div>"; } else { $data = ''; if(isset($_GET['filter']) && $_GET['filter'] != ''){ $filter = $_GET['filter']."%"; }else{ // set A as default $filter = "a%"; } $sql = "SELECT * FROM Games WHERE gametitle LIKE '$filter' ORDER BY gametitle"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 0) die("No records found"); // loop through the results returned by your query while($row = mysql_fetch_assoc($res)) { $title=$row['gametitle']; $cover=$row['cover']; $gameid=$row['gameid']; $up=$row['up']; $down=$row['down']; // directory for images $dir="coverart"; ?> <div id="cardcontainer"> <div id="coverart"> <?php echo "<img src='$dir/{$cover}' width='100' height='140'><br>"; ?> </div> <div id="gametitle"> <a href="Reviews.php?gameid=<?php echo $gameid ?>"><?php echo $title ?></a> </div> <div id="friendrating">Rate It<br /><a href="" class="vote" id="<?php echo $gameid; ?>" name="up"><?php echo $up; ?></a></div> <div id="globalrating">Hate It<br /><a href="" class="vote" id="<?php echo $gameid; ?>" name="down"><?php echo $down; ?></a></div> </div> <br /> <?php } } ?> </body> </html> Magento 1.9 - How to include custom PHP Script into .PHTML file My magento tracking page: https://i.stack.imgur.com/3GIoN.png Back-end magento code : https://i.stack.imgur.com/ySgMA.png How can i add my PHP script into this tracking page. Tracking page code - trackorder.phtml [ https://i.stack.imgur.com/ySgMA.png ]
<?php if(Mage::getStoreConfig('trackorder/trackorder_general/enabled')): ?> <div class="page-title"><h1><?php echo $this->__('Track Your Order ') ?></h1></div> <div class="form-list"> <form name="track_order" id="track_order" action="" method="post" onsubmit="sendAjax('track_order','<?php echo Mage::getUrl('*/*/track');?>'); return false;"> <!--<form name="track_order" method="post" id="track_order" action="<?php echo Mage::getUrl('*/*/view');?>">--> <ul class="form-list"> <li> <label for="order_id" class="required"><em>*</em><?php echo $this->__('Order Id') ?></label> <div class="input-box"> <input type="text" name="order_id" id="order_id" value="" title="" class="input-text required-entry" /> </div> </li> <li> <label for="email_address" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label> <div class="input-box" > <input type="text" name="email" id="email_address" value="" title="<?php echo $this->__('Email Address') ?>" class="input-text validate-email required-entry" /> </div> </li> </ul> <div class="buttons-set"> <button type="submit" class="button" title="<?php echo $this->__('Track Order') ?>" name="track" id="track"> <span><span><?php echo $this->__('Track Order') ?></span></span> </button> </div> </form> <div id="loading-details" class="loading-details" style="display:none"> <div id="loading-mask" > <p class="loader" id="loading_mask_loader"><img src="<?php echo $this->getSkinUrl('trackorder/images/ajax-loader-tr.gif') ?>" alt="<?php echo Mage::helper('adminhtml')->__('Loading...') ?>"/><br/><?php echo $this->__('Please wait...') ?></p> </div> </div> </div> <div id="oderinfo" class="order-info-message"></div> <script type="text/javascript"> var validateForm = new VarienForm('track_order', true); </script> <script type="text/javascript"> function sendAjax(frmId,url){ if (!validateForm.validator.validate()) { return; } var data = $(frmId).serialize(this); $("loading-details").show(); new Ajax.Updater( { success:"oderinfo" }, url, { asynchronous:true, evalScripts:false, onComplete:function(request, json){ $("loading-details").hide(); return false; }, onLoading:function(request, json){}, parameters:data } ); return false; } </script> <?php else: ?> <?php $url = Mage::getBaseUrl(); Mage::app()->getFrontController()->getResponse()->setRedirect($url); ?> <?php endif; ?>
From above code how can i add my own PHP script : My PHP script :
<!DOCTYPE HTML> <html> <body> <form action="#" method="POST"> Select Courier : <select name="courier"> <option disabled='disabled' selected>-- Choose an option --</option> <option value="professional_courier">Professional Courier</option> <option value="shree_maruti_courier">Shree Maruti Courier</option> <option value="india_post_courier">India Post Courier</option> <option value="dhl_courier">DHL Courier</option> <option value="fedex_courier">Fedex Courier</option> <option value="ups_courier">UPS Courier</option> </select> Trackingid: <input type="text" name="trackingid"> <input type="submit"> </form> <?php if (isset($_POST['courier'])) { // Professional Courier if ('professional_courier' === $_POST['courier']) { header("Location: https://www.tpcindia.com/Tracking2014.aspx?id=" . $_POST["trackingid"] . "&type=0&service=0"); } // Shree Maruti Courier else if ('shree_maruti_courier' === $_POST['courier']) { header("Location: https://www.shreemaruticourier.com/track-your-shipment/#track-your", "_blank"); } // india_post_courier else if ('india_post_courier' === $_POST['courier']) { header("Location: https://www.indiapost.gov.in/vas/Pages/IndiaPostHome.aspx/#main-content", "_blank"); } // DHL Courier else if ('dhl_courier' === $_POST['courier']) { header("Location: https://www.dhl.com/en/express/tracking.html?AWB=" . $_POST["trackingid"] . "&brand=DHL", "_blank"); } // Fedex Courier else if ('fedex_courier' === $_POST['courier']) { header("Location: https://www.fedex.com/apps/fedextrack/?action=track&trackingnumber=" . $_POST["trackingid"] . "&cntry_code=in&locale=en_IN", "_blank"); } // ups_courier else if ('ups_courier' === $_POST['courier']) { header("Location: https://www.ups.com/track?loc=en_US&tracknum=" . $_POST["trackingid"] . "&requester=WT/trackdetails", "_blank"); } } ?> </body> </html>
My Workout in trackorder.phtml getting error : [start & end header added]
<?php if(Mage::getStoreConfig('trackorder/trackorder_general/enabled')): ?> <div class="page-title"><h1><?php echo $this->__('Track Your Order ') ?></h1></div> <div class="form-list" style="float: left;"> <form name="track_order" id="track_order" action="" method="post" onsubmit="sendAjax('track_order','<?php echo Mage::getUrl('*/*/track');?>'); return false;"> <!--<form name="track_order" method="post" id="track_order" action="<?php echo Mage::getUrl('*/*/view');?>">--> <ul class="form-list"> <li> <label for="order_id" class="required"><em>*</em><?php echo $this->__('Order Id') ?></label> <div class="input-box"> <input type="text" name="order_id" id="order_id" value="" title="" class="input-text required-entry" /> </div> </li> <li> <label for="email_address" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label> <div class="input-box" > <input type="text" name="email" id="email_address" value="" title="<?php echo $this->__('Email Address') ?>" class="input-text validate-email required-entry" /> </div> </li> </ul> <div class="buttons-set"> <button type="submit" class="button" title="<?php echo $this->__('Track Order') ?>" name="track" id="track"> <span><span><?php echo $this->__('Track Order') ?></span></span> </button> </div> </form> <div id="loading-details" class="loading-details" style="display:none"> <div id="loading-mask" > <p class="loader" id="loading_mask_loader"><img src="<?php echo $this->getSkinUrl('trackorder/images/ajax-loader-tr.gif') ?>" alt="<?php echo Mage::helper('adminhtml')->__('Loading...') ?>"/><br/><?php echo $this->__('Please wait...') ?></p> </div> </div> </div> <!-- Start couier tracking --> <div style="float: left;"> <form action="#" method="POST" style="padding: 28px 15px 21px 196px;"> Select Courier : <select name="courier"> <option disabled='disabled' selected>-- Choose an option --</option> <option value="professional_courier">Professional Courier</option> <option value="shree_maruti_courier">Shree Maruti Courier</option> <option value="india_post_courier">India Post Courier</option> <option value="dhl_courier">DHL Courier</option> <option value="fedex_courier">Fedex Courier</option> <option value="ups_courier">UPS Courier</option> </select> Trackingid: <input type="text" name="trackingid"> <input type="submit"> </form> <?php if (isset($_POST['courier'])) { // Professional Courier if ('professional_courier' === $_POST['courier']) { header("Location: https://www.tpcindia.com/Tracking2014.aspx?id=" . $_POST["trackingid"] . "&type=0&service=0"); } // Shree Maruti Courier else if ('shree_maruti_courier' === $_POST['courier']) { header("Location: https://www.shreemaruticourier.com/track-your-shipment/#track-your", "_blank"); } // india_post_courier else if ('india_post_courier' === $_POST['courier']) { header("Location: https://www.indiapost.gov.in/vas/Pages/IndiaPostHome.aspx/#main-content", "_blank"); } // DHL Courier else if ('dhl_courier' === $_POST['courier']) { header("Location: https://www.dhl.com/en/express/tracking.html?AWB=" . $_POST["trackingid"] . "&brand=DHL", "_blank"); } // Fedex Courier else if ('fedex_courier' === $_POST['courier']) { header("Location: https://www.fedex.com/apps/fedextrack/?action=track&trackingnumber=" . $_POST["trackingid"] . "&cntry_code=in&locale=en_IN", "_blank"); } // ups_courier else if ('ups_courier' === $_POST['courier']) { header("Location: https://www.ups.com/track?loc=en_US&tracknum=" . $_POST["trackingid"] . "&requester=WT/trackdetails", "_blank"); } } ?> </div> <!-- End couier tracking --> <div id="oderinfo" class="order-info-message"></div> <script type="text/javascript"> var validateForm = new VarienForm('track_order', true); </script> <script type="text/javascript"> function sendAjax(frmId,url){ if (!validateForm.validator.validate()) { return; } var data = $(frmId).serialize(this); $("loading-details").show(); new Ajax.Updater( { success:"oderinfo" }, url, { asynchronous:true, evalScripts:false, onComplete:function(request, json){ $("loading-details").hide(); return false; }, onLoading:function(request, json){}, parameters:data } ); return false; } </script> <?php else: ?> <?php $url = Mage::getBaseUrl(); Mage::app()->getFrontController()->getResponse()->setRedirect($url); ?> <?php endif; ?>
This topic has been moved to Editor Help (Dreamweaver, Zend, etc). http://www.phpfreaks.com/forums/index.php?topic=306796.0 Hi everyone! I've been working on a php script to replace links that contain a query with direct links to the files they would redirect to. I'm having trouble echoing $year in my script. Listed below is the script, just below ,$result = mysql_query("SELECT * FROM $dbname WHERE class LIKE '%$search%'") or die(mysql_error());, in the script I try to echo $year. It doesn't show up in the table on the webpage. Everything else works fine. Any help wold be appreciated greatly. Thanks in advance. <?php include 'config2.php'; $search=$_GET["search"]; // Connect to server and select database. mysql_connect($dbhost, $dbuser, $dbpass)or die("cannot connect"); mysql_select_db("vetman")or die("cannot select DB"); $result = mysql_query("SELECT * FROM $dbname WHERE class LIKE '%$search%'") or die(mysql_error()); // store the record of the "" table into $row //$current = ''; echo "<table align=center border=1>"; echo "<br>"; echo "<tr>"; echo "<td align=center>"; ?> <div style="float: center;"><a><h1><?php echo $year; ?></h1></a></div> <?php echo "</td>"; echo "</tr>"; echo "</table>"; // keeps getting the next row until there are no more to get if($result && mysql_num_rows($result) > 0) { $i = 0; $max_columns = 2; echo "<table align=center>"; echo "<br>"; while($row = mysql_fetch_array($result)) { // make the variables easy to deal with extract($row); // open row if counter is zero if($i == 0) echo "<tr>"; echo "<td align=center>"; ?> <div style="float: left;"> <div><img src="<?php echo $image1; ?>"></div> </div> <?php echo "</td>"; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo "</tr>"; $i=0; } // end if } // end while } // end if results // clean up table - makes your code valid! if($i > 0) { for($j=$i; $j<$max_columns;$j++) echo "<td> </td>"; echo '</tr>'; } mysql_close(); ?> </table> Hi i have this upload script which works fine it uploads image to a specified folder and sends the the details to the database. but now i am trying to instead make a modify script which is Update set so i tried to change insert to update but didnt work can someone help me out please this my insert image script which works fine but want to change to modify instead Code: [Select] <?php mysql_connect("localhost", "root", "") or die(mysql_error()) ; mysql_select_db("upload") or die(mysql_error()) ; // my file the name of the input area on the form type is the extension of the file //echo $_FILES["myfile"]["type"]; //myfile is the name of the input area on the form $name = $_FILES["image"] ["name"]; // name of the file $type = $_FILES["image"]["type"]; //type of the file $size = $_FILES["image"]["size"]; //the size of the file $temp = $_FILES["image"]["tmp_name"];//temporary file location when click upload it temporary stores on the computer and gives it a temporary name $error =array(); // this an empty array where you can then call on all of the error messages $allowed_exts = array('jpg', 'jpeg', 'png', 'gif'); // array with the following extension name values $image_type = array('image/jpg', 'image/jpeg', 'image/png', 'image/gif'); // array with the following image type values $location = 'images/'; //location of the file or directory where the file will be stored $appendic_name = "news".$name;//this append the word [news] before the name so the image would be news[nameofimage].gif // substr counts the number of carachters and then you the specify how how many you letters you want to cut off from the beginning of the word example drivers.jpg it would cut off dri, and would display vers.jpg //echo $extension = substr($name, 3); //using both substr and strpos, strpos it will delete anything before the dot in this case it finds the dot on the $name file deletes and + 1 says read after the last letter you delete because you want to display the letters after the dot. if remove the +1 it will display .gif which what we want is just gif $extension = strtolower(substr($name, strpos ($name, '.') +1));//strlower turn the extension non capital in case extension is capital example JPG will strtolower will make jpg // another way of doing is with explode // $image_ext strtolower(end(explode('.',$name))); will explode from where you want in this case from the dot adn end will display from the end after the explode $myfile = $_POST["myfile"]; if (isset($image)) // if you choose a file name do the if bellow { // if extension is not equal to any of the variables in the array $allowed_exts error appears if(in_array($extension, $allowed_exts) === false ) { $error[] = 'Extension not allowed! gif, jpg, jpeg, png only<br />'; // if no errror read next if line } // if file type is not equal to any of the variables in array $image_type error appears if(in_array($type, $image_type) === false) { $error[] = 'Type of file not allowed! only images allowed<br />'; } // if file bigger than the number bellow error message if($size > 2097152) { $error[] = 'File size must be under 2MB!'; } // check if folder exist in the server if(!file_exists ($location)) { $error[] = 'No directory ' . $location. ' on the server Please create a folder ' .$location; } } // if no error found do the move upload function if (empty($error)){ if (move_uploaded_file($temp, $location .$appendic_name)) { // insert data into database first are the field name teh values are the variables you want to insert into those fields appendic is the new name of the image mysql_query("INSERT INTO image (myfile ,image) VALUES ('$myfile', '$appendic_name')") ; exit(); } } else { foreach ($error as $error) { echo $error; } } //echo $type; ?> Hello, I stored a fsockopen function in a separate "called.php" file, in order to run it as another thread when it needs. The called script should return results to the "master.php" script. I'm able to run the script to get the socket working, and I'm able to get results from the called script. I tried for hours but I can't do the twice both My master.php script (with socket working): Code: [Select] <?php $command = "(/mnt/opt/www/called.php $_SERVER[REMOTE_ADDR] &) > /dev/null"; $result = exec($command); echo ("result = $result\r\n"); ?> and my called.php script Code: [Select] #!/mnt/opt/usr/bin/php-cli -q <?php $device = $_SERVER['argv'][1]; $port = "8080"; $fp = fsockopen($device, $port, $errno, $errstr, 5); fwrite($fp, "test"); fclose($fp); echo ("normal end of the called.php script"); ?> In the master script, if I use Code: [Select] $command = "(/mnt/opt/www/called.php $_SERVER[REMOTE_ADDR] &) > /dev/null"; the socket works, but I have nothing in $result (note also that I don't anderstand why the ( ... &) are needed!?) and if I use Code: [Select] $command = "/mnt/opt/www/called.php $_SERVER[REMOTE_ADDR]"; I have the correct text "normal end of the called.php script" in $result but the socket connection is not performed (no errors in php logs) Could you help me to find a way to let's work the two features correctly together? Thank you. hey guys im really just after a bit of help/information on 2 things (hope its in the right forum).
1. basically I'm wanting to make payments from one account to another online...like paypal does...im wondering what I would need to do to be able to do this if anyone can shine some light please?
2.as seen on google you type in a query in the search bar and it generates sentences/keywords from a database
example:
so if product "chair" was in the database
whilst typing "ch" it would show "chair" for a possible match
I know it would in tale sql & json but im after a good tutorial/script of some sort.
if anyone can help with some information/sites it would be much appreciated.
Thank you
Well the subject line is pretty explicit. I found this script that uploads a picture onto a folder on the server called images, then inserts the the path of the image on the images folder onto a VACHAR field in a database table. Code: [Select] <?php //This file inserts the main image into the images table. //address error handling ini_set ('display_errors', 1); error_reporting (E_ALL & ~E_NOTICE); //authenticate user //Start session session_start(); //Connect to database require ('config.php'); //Check whether the session variable id is present or not. If not, deny access. if(!isset($_SESSION['id']) || (trim($_SESSION['id']) == '')) { header("location: access_denied.php"); exit(); } else{ // Check to see if the type of file uploaded is a valid image type function is_valid_type($file) { // This is an array that holds all the valid image MIME types $valid_types = array("image/jpg", "image/jpeg", "image/bmp", "image/gif"); if (in_array($file['type'], $valid_types)) return 1; return 0; } // Just a short function that prints out the contents of an array in a manner that's easy to read // I used this function during debugging but it serves no purpose at run time for this example function showContents($array) { echo "<pre>"; print_r($array); echo "</pre>"; } // Set some constants // This variable is the path to the image folder where all the images are going to be stored // Note that there is a trailing forward slash $TARGET_PATH = "images/"; // Get our POSTed variable $image = $_FILES['image']; // Sanitize our input $image['name'] = mysql_real_escape_string($image['name']); // Build our target path full string. This is where the file will be moved to // i.e. images/picture.jpg $TARGET_PATH .= $image['name']; // Make sure all the fields from the form have inputs if ( $image['name'] == "" ) { $_SESSION['error'] = "All fields are required"; header("Location: member.php"); exit; } // Check to make sure that our file is actually an image // You check the file type instead of the extension because the extension can easily be faked if (!is_valid_type($image)) { $_SESSION['error'] = "You must upload a jpeg, gif, or bmp"; header("Location: member.php"); exit; } // Here we check to see if a file with that name already exists // You could get past filename problems by appending a timestamp to the filename and then continuing if (file_exists($TARGET_PATH)) { $_SESSION['error'] = "A file with that name already exists"; header("Location: member.php"); exit; } // Lets attempt to move the file from its temporary directory to its new home if (move_uploaded_file($image['tmp_name'], $TARGET_PATH)) { // NOTE: This is where a lot of people make mistakes. // We are *not* putting the image into the database; we are putting a reference to the file's location on the server $sql = "insert into images (member_id, image_cartegory, image_date, image) values ('{$_SESSION['id']}', 'main', NOW(), '" . $image['name'] . "')"; $result = mysql_query($sql) or die ("Could not insert data into DB: " . mysql_error()); header("Location: images.php"); echo "File uploaded"; exit; } else { // A common cause of file moving failures is because of bad permissions on the directory attempting to be written to // Make sure you chmod the directory to be writeable $_SESSION['error'] = "Could not upload file. Check read/write persmissions on the directory"; header("Location: member.php"); exit; } } //End of if session variable id is not present. ?> The script seems to work fine because I managed to upload a picture which was successfully inserted into my images folder and into the database. Now the problem is, I can't figure out exactly how to write the script that displays the image on an html page. I used the following script which didn't work. Code: [Select] //authenticate user //Start session session_start(); //Connect to database require ('config.php'); $sql = mysql_query("SELECT* FROM images WHERE member_id = '".$_SESSION['id']."' AND image_cartegory = 'main' "); $row = mysql_fetch_assoc($sql); $imagebytes = $row['image']; header("Content-type: image/jpeg"); print $imagebytes; Seems to me like I need to alter some variables to match the variables used in the insert script, just can't figure out which. Can anyone help?? I have an application which runs on more than one server and need to launch one PHP script from another PHP script. Since this is different than a function call I'm not sure how it's done. I plan to include parameters in the URL I send and use GETs to pick up parameters in the "called" PHP script. Thanks for sugestions How would I go about making it to where,, I can tell the script to use a certain extension of php in the script like curl.. ? Thanks Hi, I am trying to run two scripts on one page. When I use just one script on the page they work however when I place both scripts on the same page one of them disrupts the other script. This script prevents the other following script from working: Code: [Select] ini_set('display_errors', 1); error_reporting(-1); { $query = "SELECT * FROM answers ORDER BY `aid` DESC LIMIT 0, 11"; } $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { $answer = $row['answer']; $aid = $row['aid']; echo " <div class='questionboxquestion'> <a href= 'http://www.domain.co.uk/test/easy/answer.php?aid=$aid' class='questionlink'>$answer</a> </div> <div class='questionboxnotes'> </br> </div> <div class='questionboxlinks'> <div class='questionboxcategory'> <div class='questionboxcategorytitle'> Category: </div> <a href= 'http://www.domain.co.uk/test/easy/furniture-category.php' class='questionanswerlink'></a> </div> <div class='questionboxanswerlink'> <a href= 'http://www.domain.co.uk/test/oeasy/index.php' class='questionanswerlink'>Answer</a> </div> </div> "; } Code: [Select] <?php if($error) echo "<span style=\"color:#ff0000;\">".$error."</span><br /><br />"; ?> <label for="username">Username: </label> <input type="text" name="username" value="<?php if($_POST['username']) echo $_POST['username']; ?>" /><br /> <label for="password">Password: </label> <input type="password" name="password" value="<?php if($_POST['password']) echo $_POST['password']; ?>" /><br /> <label for="password2">Retype Password: </label> <input type="password" name="password2" value="<?php if($_POST['password2']) echo $_POST['password2']; ?>" /><br /> <label for="email">Email: </label> <input type="text" name="email" value="<?php if($_POST['email']) echo $_POST['email']; ?>" /><br /><br /> <input type="submit" name="submit" value="Register" /> i want to help with my php scrip coz every hackd my script so please anyone help me for make secure script. |