How to install PHP? Someone help a computer illiterate

Discussion in 'Web Design and Development' started by slipper, Jan 31, 2009.

  1. slipper macrumors 68000


    Nov 19, 2003
    Trying to install a contact form on a basic website of mine.

    I found a PHP script on this website...

    Its the third one down. The zip file that i downloaded has three PHP files and a bunch of images. Can someone explain what i do with these?
  2. angelwatt Moderator emeritus


    Aug 16, 2005
    Does the server you have support PHP? Your title says install PHP, but do you really mean install a PHP script?

    Generally you just drag and drop the files where you want them in your directory structure for your web site. Then, you'll edit some config file that's a part of the PHP script that customizes it for your need. Was there a read me file? You haven't provided much to go off of.

    Also, that script is only rated 2.4 of 5, so you may want to find a better one.
  3. slipper thread starter macrumors 68000


    Nov 19, 2003
    Im with godaddy and yes the site says they support PHP scripts.

    I realize its a matter of dropping the script in the structure of the website but what im having problems with is the three files included in the zip file i downloaded in the link i provided. They are below, can someone give me some direction as to where to put these files or how to use them?


    // img.jpg should be 75x35pixels in size...
    $RandomStr = md5(microtime());// md5 to generate the random string
    $ResultStr = substr($RandomStr,0,5);//trim 5 digit
    $NewImage =imagecreatefromjpeg("images/$img.jpg");//image create by existing image and as back ground
    $LineColor = imagecolorallocate($NewImage, 117,195,13);//line color
    $LineColor2 = imagecolorallocate($NewImage, 85,216,23);//line color
    $TextColor = imagecolorallocate($NewImage, rand(180,220), rand(150,180), rand(200,240));//text color-white 200 replaced with rand 
    imageline($NewImage,1,1,40,40,$LineColor);//create line 1 on image
    imageline($NewImage,1,100,60,0,$LineColor);//create line 2 on image
    imageline($NewImage,35,1,75,20,$LineColor2);//create line 3 on image
    imageline($NewImage,1,15,75,5,$LineColor2);//create line 4 on image
    for ($i = 0; $i <= 256; $i++) {
    $point_color = imagecolorallocate ($NewImage, rand(0,255), rand(0,255), rand(0,255));
    imagesetpixel($NewImage, rand(2,75), rand(2,35), $point_color);
    for($i=0;$i<$len;$i++) $str_array[]=$ResultStr{$i};
    imagestring($NewImage, rand(3,5), rand(2,10), rand(2,21), $str_array[0], $TextColor);// Draw a random string horizontally
    imagestring($NewImage, rand(3,5), rand(18,25), rand(8,21), $str_array[1], $TextColor);// Draw a random string horizontally
    imagestring($NewImage, rand(3,5), rand(33,40), rand(2,11), $str_array[2], $TextColor);// Draw a random string horizontally
    imagestring($NewImage, rand(4,5), rand(47,55), rand(5,21), $str_array[3], $TextColor);// Draw a random string horizontally
    imagestring($NewImage, rand(3,5), rand(61,66), rand(14,21), $str_array[4], $TextColor);// Draw a random string horizontally
    $_SESSION['key'] = $ResultStr;// carry the data through session
    header("Content-type: image/jpeg");// out out the image
    imagejpeg($NewImage);//Output image to browser
    <?php session_start(); ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    <html xmlns="" lang="en" xml:lang="en">
    <title>Script Demonstration Page</title>
    <div style="margin:0.2em 6em 0 6em;">
    <h2 style="text-align:center">PHP Script Demonstration Site</h2>
    <p>This page has been created for the purpose of demonstrating the PHP contact form written by<br/>
    The version of the form on this page incorporates a captcha image verification system to help minimise abuse and ensure that it is actually completed by a human and not some sort of robot.</p>
    <p>We encourage you to click on the submit button with all, 1 or none of the form fields filled in - you will see the error messages that are generated when this happens.  If you do use this form to do any testing, why not simply choose a <a href="">tempemail temporary email address</a> for your testing purposes.</p>
    <p>For information regarding this script and to get a copy for yourself please go to <a href="">RRWH PHP Scripts</a></p>
    <p style="text-align:center">
    <script type="text/javascript"><!--
    google_ad_client = "pub-9651312555197116";
    google_ad_width = 728;
    google_ad_height = 90;
    google_ad_format = "728x90_as";
    google_ad_type = "text";
    google_ad_channel = "";
    google_color_border = "FFFFFF";
    google_color_bg = "FFFFFF";
    google_color_link = "1A40B1";
    google_color_text = "000000";
    google_color_url = "000000";
    <script type="text/javascript"
    <?php include"contact2.php";?>
    /* Licence 
    Version 0.1 Initial 20/03/2005
    Version 0.3, 24/03/2005
    copyright 2005.
    This script is distributed under the licence conditions on the website
    ****** Usage ********
    To use: simply put <?php include("contact2.php");?> in any php web
    page to both show and process the form.
    *** Start of configuration *** 
    You will need to customise these 5 variables before you upload this to your website
    // what servers are allowed to use this to send you email
    $safe_domains = array('', '');
    // A thank you message when someone fills in the form
    $thankyou = 'Your message has been sent and we will get back to you shortly';
    // Your email address goes here the form is sent to this address
    $recipient = "";
    // The subject for the email sent to you
    $subject = 'Messages sent from website';
    // A word that checks that the form was filled in from your website to make it harder for abuse
    $doublecheck = 'A_secret_word_Z';
    // The template for the message that gets sent to you. - do not remove the <from> and <message> 
    // as these get replaced with the form details
    $form = '
    <from> has visited your website at and filled in the contact form.
    _________Start Message_________
    __________End Message__________
    /* *** End of configuration *** */
    $me = $_SERVER['PHP_SELF'];
    $linkback = '<span><font size="-5">Form Mail script provided by <a
    href="" target="_blank"></a> ©
    // Check if we are submitting the form
    if(isset($_POST['submit'])) {
    // captcha hack
    $number = $_POST['number']; 
    if ($number != $key){  $baddata = 'BAD'; echo "Error - Security code not entered or wrong <br /> <br />\n"; }
    // Check REFERER to minimise Abuse
    $i = count($safe_domains) - 1;
    while ($i >= 0) {
      if (strpos($_SERVER['HTTP_REFERER'], "http://$safe_domains[$i]")=== 0) {
        $safe = "yes";
    if ($safe != "yes") {
      echo "Error - You may not POST to this script from your previous
    location " . $_SERVER['HTTP_REFERER'] . "<br /> <br />\n";
      $baddata = 'BAD';
    // We have a valid REFERER - so continue
    // Now we want to ensure that a valid email address has been entered
    $regexp =
    $email = $_POST["email"];
    $isvalid = 'Invalid_Email_address';
    if (eregi($regexp, $email)){
            // Valid looking address
            $isvalid = 'Yes';
    if ($isvalid != 'Yes') {
            echo "Error - You entered an invalid email address - I could never
    contact you at $email <br /> <br />\n";
        $baddata = 'BAD';
    // We want to make sure a message was entered!
    $amessage = $_POST["message"];
    if ($amessage == '') {
            echo "Error - I need a message to send - you did not enter a
    message! <br /> <br />\n";
        $baddata = 'BAD';
    // print a thank you message
            if ($baddata != 'BAD'){
            print "$thankyou \n";
    // Process the submitted form or display the form to be filed in
    if(isset($_POST['submit']) && ($baddata != 'BAD')) {
                    $from = $_POST["email"];
                    $headers = "From: <$from>\r\n";
                    //$fmtMail = implode("", $form);
                    $fmtMail = str_replace("<message>", $_POST["message"], $form);
                    $fmtMail = str_replace("<from>", $_POST["name"], $fmtMail);
                    $frommail = $_SERVER["REMOTE_ADDR"];
                    $fmtMail1 = "$fmtMail \nThe message came from $frommail\n\n\n";
    // Additional check that the form was sent from your website.
                    if ($_POST["send"] == "$doublecheck") {
    // send a message to you, that includes the senders IP address
                            mail($recipient, $subject, $fmtMail1, $headers, "-f$from");
    // Send a copy of the message to the email address from the form
                            mail($from, $subject, $fmtMail, $headers, "-f$from");
    } else {
    // Present the form to be filled out
    print <<< form
    Please use this form to Contact Us. You will get a copy in your Email.
    <form action ="$me" method="post">
    Your Name: <input type="text" size="30" name="name" value="$_POST[name]"/><br />
    Your Email: <input type="text" size="30" name="email" value="$email" /><br />
    Your Message:<br />
    <textarea rows="10" cols="50" name="message">$amessage</textarea><br />
    <img src="captcha.php" height="35" width="75" alt="Security Code"/>
    Security Code: <input type="text" name="number" /><br />
    <input class="submit" type="submit" value="submit" name="submit" /> $linkback <br />
    <input type="hidden" name="send" value="$doublecheck" />
    I also have a folder with 7 small images.
  4. angelwatt Moderator emeritus


    Aug 16, 2005
    The contact.php file is just a demo page so you can toss it aside. In contact.php you'll see it gives directions on usage and configuration. It spells things out pretty well. You can place the files wherever you want. You can also rename contact2.php to a different name. So just read the directions. If you have specific questions about the instructions list those.

Share This Page