![]() |
|
|||||||
| Portal | Kayıt ol | Yardım | Üye Listesi | Ajanda | Arama | Bugünki Mesajlar | Forumları Okundu Kabul Et |
| Scriptler - Scripts Bilginiz dahilinde olan tum scriptleri burda paylasabilirsiniz ancak illegal olmamak sartiyla.You can share your scripts in here but not the illegal ones. |
Dijital Dunya Forum Sohbet
[Arşiv]
|
|||
|
|||
|
|||
|
|
![]() |
|
|
LinkBack | Seçenekler | Stil |
|
|
#1 (permalink) |
|
Junior Member
Üyelik tarihi: Jul 2007
Posts: 10
Tecrübe Puanı: 0
![]() |
Redirection Script.
Open notepad or any other HTML Editor and paste the following code. <? $URL="Your URL Here"; header ("Location: $URL"); ?> <html> <title>Your Site Title Here.</title> <head></head> <body> </body> </html> |
|
|
|
| Sponsored links | |
|
|
|
|
|
#3 (permalink) |
|
Junior Member
Üyelik tarihi: Jul 2007
Posts: 10
Tecrübe Puanı: 0
![]() |
Add a Shopping Cart to your Site
First step (setting up your database) Users ('users') table: Next to all the information you store for users you should have the following cells in you user table. ![]() It's not a problem if the fields have a different name. Just make sure that you can remember the names that are used. Do not throw different languages through each other. Also look out with HEADCASE and lowercase names. Products ('products') table: After this check we need to create an effective database structure. When I started to write this tutorial I encountered a huge problem. There are no products to test it on for me. So now we will need to make a table for our products. If you already have one, just make sure that the most important fields are inside of your table. You can also add a field for product information. Again this is just a example. You can add fields if you want more functionality. Just make sure you save a percentage the same way as I do (X / 100). Just to make it easier in the future to calculate the price with discount. Also it’s smart to save taxes in a different table. When taxes change you will only have to change 1 field. Taxes ('taxes') table Just a small table. The 'id' is the same as the taxes id in the product table. ![]() Shopping cart ('shoppingcart') table: Click here for the image Just take a good look at this table. And try to link the 'pid' and 'uid' to the right table (just to make sure you know what you are doing). You will also need to save the date and time! You will not be using this for the payment. Because a user can wait a couple of days before sending the order. This date will give users the ability to look back at orders they have made. Even if you are not going to use it, it is still smart to save it. Because you will not be able to add this in the future if there are already products in the database. The check field is for checking if the product is already ordered or not. I prefer to use for true a '1' and for false a '0'. Please, check everything before you go on with the following step. Second step (inserting products into the shopping cart) Now we are going to try to make everything work. You will need to do a lot yourself. I will not write the script for you, because you won't learn anything if I do that. Maybe you are already able to go on for yourself. The hardest part is done for you in the previous step, just make sure that you make a good documentation. Just like I did in Excel. These projects will take more then one day and you don't want to start all over again. Ok, let's move on. You should first make a page that shows the products. In this page you can place an order form that goes to a page that inserts the product in the shopping cart. Just take a look at a existing e-commerce website. The form requires two fields. In the first field the user can set the amount of products. I used the name 'amount' for the amount of products that is going to be ordered. The other field is a hidden field where you can store the product id ('pid'). A button will submit the field. The handling page should look like this: CODE INSERT INTO shoppingcart (pid, uid, amount) VALUE ('" . $pid . "', '" . $uid . "', '" . $amount . "') The field 'uid' is the id of the user (probably from a session). The date and time shouldn't be inserted yet! Like I've said before, that's the date and time the user orders the product not the date and time of placing it in the shopping cart. If you're able to insert products into your shopping cart you can make the shopping cart itself. The shopping cart is the page that shows the products that is in the user's list. The select query will look like the one below: CODE SELECT * FROM shoppingcart WHERE uid = '" . $uid . "' AND check = '0' Make sure that the user can do three things in his shopping cart: Edit, delete and ordering the products. Last step (products check out) When the user makes the decision to buy the products he can go to his shopping cart and click on a large order button. Behind the order button will be a php script that handles this check out. The php file that handles the check out will do a couple of things: 1. Notifying the owner of the shop that there are products ordered. This can be done by e-mail, but you can also choose for an admin page. The admin page will show which products are ordered, the date of the order and the user that ordered the product. You can use the existing shopping cart table for this page. Off course you can also send all these information to a mail box, but you'll get in trouble if there are to many orders. 2. Updating the ordered products. Setting 'check' to 1, 'date' and 'time'. 3. Confirming the order by sending an e-mail to the user. |
|
|
|
|
|
#4 (permalink) |
|
Junior Member
Üyelik tarihi: Jul 2007
Posts: 10
Tecrübe Puanı: 0
![]() |
Create a File Upload System on your Website
Step 1. First of all you have to check your PHP settings whether it is enabled to upload files. It is quite easy, you just need to call the phpinfo() function which summerize tha actual PHP settings. Such an info script is very simple.My info.php looks like this: <?php phpinfo(); ?> You have to check 3 parameters in the output. These are the followings:
If the file upload is not enabled than set it in the php.ini file to on or contact with your system administrator. If everything is correct thane we can jump to the next step. Step 2. To allow a visitor to upload a file from the browser first of all we need to create an upload form. HTML forms have a special input types called “file” which stands from an input box and a Browse button. With this the visitor can select a file and its name and path will be copied into the input field. In this tutorial we create a quite simple form. It contains only the file input field and a submit button. The form looks like this: <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="fileForm" enctype="multipart/form-data"> File to upload: <table> <tr><td><input name="upfile" type="file"></td></tr> <tr><td><input type="submit" name="submitBtn" value="Upload"></td></tr> </table> </form> As you can see the form action is to call this script again. Besides this there is one interesting part in the form tag. The parameter: enctype="multipart/form-data" This is a very important part of a file upload form. Without this parameter the upload will not work. Step 3. Now as the form is ready let's take care with the processing part. The script calls itself as result the form action parameter. To check whether the form was submitted we need to look after the "submitBtn" value in the PHP super global POST array. If it is set than the form was submitted and so we can start with the processing. When the form was submitted the file is transferred to the web server. The file will be stored in the location defined by the upload_tmp_dir PHP environment variable. The name of the file is a random generated file name so if you upload the demo.txt you will not find it with this name in the temporary directory. So here we need to define a target directory where we want to store the uploaded file. We will move the file from the temporary directory to this location. In case of a file upload PHP fills the $_FILES super global array with file information such as:
Regarding this information you can apply some more specific validation. For example you can limit the file size or file type. Now as you have this information you can create a new file name with the path on the server and move the file from the temporary directory to the real target by using the PHP built in function: move_uploaded_file(). The return value of the function will show you whether the file upload was success or not. And that was all. The basic upload script is ready. The complete upload script looks like this: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html> <body> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="fileForm" enctype="multipart/form-data"> File to upload: <table> <tr><td><input name="upfile" type="file"></td></tr> <tr><td><input type="submit" name="submitBtn" value="Upload"></td></tr> </table> </form> <?php if (isset($_POST['submitBtn'])){ // Define the upload location $target_path = "c:\\"; // Create the file name with path $target_path = $target_path . basename( $_FILES['upfile']['name']); // Try to move the file from the temporay directory to the defined. if(move_uploaded_file($_FILES['upfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['upfile']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } } ?> </body> |
|
|
|
|
|
#6 (permalink) |
|
Junior Member
Üyelik tarihi: Jul 2007
Posts: 10
Tecrübe Puanı: 0
![]() |
Learn to Make Verification Pictures
function randomString($length) { // Generate random 32 charecter string $string = md5(time()); // Position Limiting $highest_startpoint = 32-$length; // Take a random starting point in the randomly // Generated String, not going any higher then $highest_startpoint $randomString = substr($string,rand(0,$highest_startpoint),$length ); return $randomString; } ?> < ?php // Gets a random string of length 10 $randomString = randomString(10); ?> |
|
|
|
|
|
#10 (permalink) |
|
Junior Member
Üyelik tarihi: Jul 2007
Posts: 10
Tecrübe Puanı: 0
![]() |
Add Watermark to your Images.
<form name="submit_image" method="post" enctype="multipart/form-data" action=""> <input type="file" name="image"> <input name="Submit" type="submit" value="Upload Picture"> </form> function copy_marked($img_name,$newname,$type) { // check image type. The image type is sent as parameter 3 ($type). Note that for every image type a different function is used to create an image in memory from the uploaded file. if(!strcmp("image/jpg",$type) || !strcmp("image/jpeg",$type) || !strcmp("image/pjpeg",$type)) $src_img=imagecreatefromjpeg($img_name); if(!strcmp("image/png",$type)) $src_img=imagecreatefrompng($img_name); if(!strcmp("image/gif",$type)) $src_img=imagecreatefromgif($img_name); // get image size, we'll need it later $old_x=imageSX($src_img); $old_y=imageSY($src_img); // create destination image $dst_img=ImageCreateTrueColor($old_x,$old_y); imagecopyresampled($dst_img,$src_img,0,0,0,0,$old_ x,$old_y,$old_x,$old_y); // on this demo, the watermark image will be named watermark.gif and will be located in images folder. If you intend to use other file, you will have to change this $watermark_file='images/watermark.gif'; // you can setup the transparency used for watermark image. $transparency=50; // just in case you don't know what extension the watermark file has. This function is listed lower $wext=getFileExtension('images/watermark.gif'); // create an image from watermark file if(!strcmp("jpg",$wext) || !strcmp("jpeg",$wext)) $watermark=imagecreatefromjpeg($watermark_file); if(!strcmp("png",$wext)) $watermark=imagecreatefrompng($watermark_file); if(!strcmp("gif",$wext)) $watermark=imagecreatefromgif($watermark_file); // get watermark width $watermark_width = imagesx($watermark); $watermark_height = imagesy($watermark); // place watermark image on the right left of the main image $dest_x = $old_x - $watermark_width - 5; $dest_y = $old_y - $watermark_height - 5; // uncomment these lines and comment the ones above if you want to place the watermark in the very center of the image // $dest_x = (($thumb_w - $watermark_width)/2); // $dest_y = (($thumb_h - $watermark_height)/2); // merge the two images imagecopymerge($dst_img, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, $transparency); // copy the new created image to the destination file, in the images folder if(!strcmp("image/png",$type)) imagepng($dst_img,$newname); else if(!strcmp("image/gif",$type)) imagegif($dst_img,$newname); else imagejpeg($dst_img,$newname); // delete the images from memory imagedestroy($dst_img); imagedestroy($src_img); Function getFileExtension(), needed to get the file extension function getFileExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } Verifying if($_SERVER['REQUEST_METHOD']=='POST') { if ($_FILES['image']['name']) { $image=$_FILES['image']['name']; $newname="images/".$image; copy_marked($_FILES['image']['tmp_name'],$newname,$_FILES['image']['type']); } } |
|
|
|
![]() |
| Bookmarks |
| Konuyu Toplam 1 Üye okuyor. (0 Kayıtlı üye ve 1 Misafir) | |
| Seçenekler | |
| Stil | |
|
|