• On-Line Training

      0 comments

    images

    I just posted an ad from Lynda.com on my site. Reason for this is that of all of the on-line training sites that I have looked over or used this is by far the best one. There literally nothing that you can not find a class for and I assure you that you will learn a ton from the class that you do.

  • Add Pictures With PHP

      0 comments

    I found code that you can use to be able to upload pictures to a MySQL server with PHP. This is useful code to use if you are making a Contact Management System or a back end system for yourself or your client so that they can upload photos to a database which will then be echoed back to your server. I put this together using phpMyAdmin, MySQL and Dreamweaver CS4.

    First thing you need to do is to go in to your phpMyAdmin program. Click the tab SQL and then cut and paste in this text to create the proper database for the php code below:

    CREATE TABLE IF NOT EXISTS `files` (
    `fid` int(11) NOT NULL AUTO_INCREMENT COMMENT ‘unique id’,
    `name` varchar(30) NOT NULL COMMENT ‘file name’,
    `type` varchar(30) NOT NULL COMMENT ‘MIME type’,
    `size` int(11) NOT NULL COMMENT ‘file size’,
    `content` mediumblob NOT NULL COMMENT ‘actual file’,
    `description` varchar(100) NOT NULL,
    PRIMARY KEY (`fid`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COMMENT=’Uploaded files’ AUTO_INCREMENT=7 ;

    Open an html page and save it as “form.html”. Then place in this code between the body tags:

    <form action=”upload.php” method=”post” enctype=”multipart/form-data” name=”uploadform”>
    <input type=”hidden” name=”MAX_FILE_SIZE” value=”350000″>
    <input name=”picture” type=”file” id=”picture” size=”50″>
    <input name=”upload” type=”submit” id=”upload” value=”Upload Picture!”>
    </form>

    Now open a new php page and save it as upload.php making sure you are saving it in the same folder as the form.html.

    <?php require_once(‘your connection‘); ?>

    <?php

    // if something was posted, start the process…
    if(isset($_POST['upload']))
    {

    // define the posted file into variables
    $name = $_FILES['picture']['name'];
    $tmp_name = $_FILES['picture']['tmp_name'];
    $type = $_FILES['picture']['type'];
    $size = $_FILES['picture']['size'];

    // get the width & height of the file (we don’t need the other stuff)
    list($width, $height, $typeb, $attr) = getimagesize($tmp_name);

    // if width is over 600 px or height is over 500 px, kill it
    if($width>600 || $height>500)
    {
    echo $name . “‘s dimensions exceed the 600×500 pixel limit.”;
    echo  “<a href=\”form.php\”>Click here to try again.</a>”;
    die();
    }

    // if the mime type is anything other than what we specify below, kill it
    if(!(
    $type==’image/jpeg’ ||
    $type==’image/png’ ||
    $type==’image/gif’
    )) {
    echo $type .  ” is not an acceptable format.”;
    echo  “<a href=\”form.php\”>Click here to try again.</a>”  ;
    die();
    }

    // if the file size is larger than 350 KB, kill it
    if($size>’350000′) {
    echo $name . ” is over 350KB. Please make it smaller.”;
    echo “<a href=\”form.php\”>Click here to try again. </a>”  ;

    die();
    }
    // if your server has magic quotes turned off, add slashes manually
    if(!get_magic_quotes_gpc()){
    $name = addslashes($name);
    }

    // open up the file and extract the data/content from it
    $extract = fopen($tmp_name, ‘r’);
    $content = fread($extract, $size);
    $content = addslashes($content);
    fclose($extract);  ?>

    <?php  // connect to the database
    include(‘your connection‘); ?>
    <?php
    // the query that will add this to the database
    $addfile = “INSERT INTO files (name, size, type, content, description ) “.
    “VALUES (‘$name’, ‘$size’, ‘$type’, ‘$content’, ‘$description’)”;

    mysql_query($addfile) or die(mysql_error());

    // get the last inserted ID if we’re going to display this image next
    $inserted_fid = mysql_insert_id();

    mysql_close();
    // display the image
    ?>
    <div align=”center”>
    <strong><? echo $name; ?><br>
    </strong><img name=”<? echo $name; ?>” src=”getpicture.php?fid=<? echo $inserted_fid; ?>” alt=”Unable to view image #<? echo $inserted_fid; ?>”>
    <br>
    <a href=”upload.php”>upload more images</a>
    </div>
    <p>
    <?
    // we still have to close the original IF statement. If there was nothing posted, kill the page.
    }else{die(“No uploaded file present”);
    }
    ?>

    Now open a new php file and save it as getpicture.php and drop in this code:

    <?php

    if(isset($_GET['fid']))
    {
    // connect to the database

    include "your connection";

    // query the server for the picture
    $fid = $_GET['fid'];
    $query = “SELECT * FROM files WHERE fid = ’$fid’”;
    $result = mysql_query($query) or die(mysql_error());

    // define results into variables
    $name=mysql_result($result,0,”name”);
    $size=mysql_result($result,0,”size”);
    $type=mysql_result($result,0,”type”);
    $content=mysql_result($result,0,”content”);

    // give our picture the proper headers…otherwise our page will be confused
    header(“Content-Disposition: attachment; filename=$name”);
    header(“Content-length: $size”);
    header(“Content-type: $type”);
    echo $content;

    mysql_close();
    }else{
    die(“No file ID given…”);
    }
    ?>

    Now that should do it for you.  From there you can set this up to work in several different formats but now you have the ability to upload photos and then have them show. Any questions please let me know.

  • PHP Form That Sends You An Email

      1 comment

    When making  a form on a website there are several options of where you want that information to go, either a database or to your email. This would be done with a site that you have a form that gathers information from a client who is requesting more information. For some time now I have been trying to work out how to have both actions, send the data to a database and to my email. This way I have captured the clients information in a database which I can then use to contact them at a later date. Having to go to my email helps me know who is trying to reach me about their website.

    Now I have it set up so that both can happen and here is the php code for it for the form:

    <?php
    } else {
    ?>
    <form action=”test.php” method=”post”>
    <table width=”400″ border=”0″ align=”center” cellspacing=”2″ cellpadding=”0″>
    <tr>
    <td width=”29%”>Your name:</td>
    <td width=”71%”><input name=”name” type=”text” id=”name” size=”32″></td>
    </tr>
    <tr>
    <td>Email address:</td>
    <td><input name=”email” type=”text” id=”email” size=”32″></td>
    </tr>
    <tr>
    <td>Comment:</td>
    <td><textarea name=”comment” cols=”45″ rows=”6″ id=”comment”></textarea></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td align=”left” valign=”top”><input type=”submit” name=”Submit” value=”Send”></td>
    </tr>
    </table>
    </form> ?>

    Here is the code for the email action:

    <?php
    if ($_POST["email"]<>”) {
    $ToEmail = ‘youremail@site.com’;
    $EmailSubject = ‘Site contact form ‘;
    $mailheader = “From: “.$_POST["email"].”\r\n”;
    $mailheader .= “Reply-To: “.$_POST["email"].”\r\n”;
    $mailheader .= “Content-type: text/html; charset=iso-8859-1\r\n”;
    $MESSAGE_BODY = “Name: “.$_POST["name"].”<br>”;
    $MESSAGE_BODY .= “Email: “.$_POST["email"].”<br>”;
    $MESSAGE_BODY .= “Comment: “.nl2br($_POST["comment"]).”<br>”;
    mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die (“Failure”);
    ?>}

    Couple of points that you need to pay close attention to in the email PHP code is that you need to fill in the $ToEmail variable so that it has your email address that you are sending it to. Also, make sure that the other variable’s strings throughout the form match the tables id’s. For example: $mailheader = “From: “.$_POST["email"].”\r\n”; the area $_POST["email"] is the id for the form which you will have to match with the database row. With my site I have it like this: $mailheader = “From: “.$_POST["txtEmail"].”\r\n”;. The txtEmail represents my row in the table for my database. So make you go through and match this up.

    Very, very important update! You will need to add this hidden field just below the submit but still in the <form></form> area “<input name=”email” type=”hidden” id=”admin@linkedupdesign.com” value=”email” />”. The email will not be sent unless you have this in there. This is the hidden field that tells the <?php?> to work!!  make sure that the value=”email” and the name=”email” stay the same because that is the global $_POST variable name.

    I have this email PHP code set up just about the form but not part of the <form></form>. Reason being is the form action is the recordset to post in to the databse so you don’t want to cross wires per say. These will be two separate action in the form.

    If you have any questions about this please feel free to get in touch with me.

  • Social Media Marketing “Twitter”

      0 comments

    Social Media Marketing has been a subject that I have been a bit backed off from for a few months now thinking that it is a bit immature use of the internet for a company. In fact as I started looking in to it more and more I still felt this way. Why the hell would I as a business owner and a designer, tweet? Actually until 2 days ago, I did not even know what the hell a tweet was.

    As I studied more and more about this I started to think, the internet has been around realistically for about 15 years lets say so to say anything is immature about the internet is a bit early. Here you have one of the most amazing forum to work from, anyone or any company can put up a website and with the right SEO work done on it, the site will have the ability to make the company a lot of money for very little money spent in comparison.

    I set up a twitter account as well as a facebook page today. I am still not digging the value of the twitter account but it does have some great advantages to the right type of company that needs to stay in touch with its fans or followers. The advantage I see to it is in a retail sense. Let’s say you have a cupcake company and you would like to drive in clients so you tweet to your follower that you are offering a 3 for 2 sale for your follows that come in with a tweet promotional code. Maybe you are launching a new product or you have really good news that you clients need to be made aware of, or, or , or. Another point I thought of was for a client that is an actor and filmmaker. Tweets can be used to instantly tell people what is going on with future projects or if he is looking for a particular location to film in so he needs to reach out right away.

    Think that I am underplaying it a bit? I might be, I will have to use it some more so become a follower to my company and we will see what we can do with it, maybe I will offer 20% off SEO work with a tweet promotional code.

  • Setting Up Testing Server Dreamweaver CS4

      5 comments

    dreamweaver_cs4_150x150

    On several occasions I have tried to set up to a database via Dreamweaver and I would get an error saying that Dreamweaver could not find a proper Testing Server. I have run in to this problem a few times now while working with Dreamweaver CS4 because I keep forgetting to write up what to do to handle it.

    I went on to the Dreamweaver help page and the only thing I can say is that engineers should not write instructions, bahh, if I was smart enough to understand what is said, I could write my own programs like Dreamweaver! I will take this up another day.

    Finally I remembered what I did in the past so here it is:

    This is what you would you would do only after you have set up the site and remote server:

    • SERVER MODEL: PHP MySQL
    • ACCESS: FTP
    • FTP HOST: ftp.site.com
    • HOST DIRECTOR: (leave blank)
    • LOGIN: login
    • PASSWORD: password
    • URL PREFIX: (this usually defaults to “http://ftp.site.com) change to “http://www.site.com”

    This last line is where I usually screw up by keeping the default setting where I then spend the next 100 hours trying to figure this out.

    Do take the note from Dreamweaver’s help page:

    Note: As of Dreamweaver CS4, Dreamweaver no longer installs ASP.NET or JSP server behaviors. If you’re working on ASP.NET or JSP pages, however, Dreamweaver will still support Live Mode, code coloring, and code hinting for those pages. You do not need to select ASP.NET or JSP in the Site Definition dialog box for any of these features to work.


SEO Powered by Platinum SEO from Techblissonline