Need guidance please ...

Discussion in 'Software' started by motdaugrnds, Oct 13, 2013.

  1. motdaugrnds

    motdaugrnds Private E-2

    I'm creating a store to sell about 30 items. I have it pretty much done; but am stuck on a "contact me" form. I'm looking for one that has some safety built into it.

    I know you all probably do not help with such matters; but I thought maybe you could direct me to where I might find such help. There are many html sites and I've spent the last few days reading all I could find. The ones that might work need a file with a PHP extension and my editor (Note Tab Light) does not show that as an option. Do I need a special program to create a php file?
     
  2. bluelogic

    bluelogic Private E-2

    look into PHP FORM PROCESSORS or PHP FORM PARSERS, or SIMPLE PHP FORM SCRIPT
     
  3. LI_Geek_95

    LI_Geek_95 Post-and-Run Geek

    Hello!

    Most web servers have PHP processors on them, so you should be okay. As far as making the file, you just need to save it with the filetype .php

    You can have html and php in the same file, in fact, generally speaking, that's how it's done.

    Here's a quick example:

    You will have to download this file, and put it in the same directory as the contact form, with the original, rita.ttf. This is the font file for the safety.

    PHP:
    <?php
    if($_POST['action'] == 'submit')
    {
     if(
    hash('ripemd128'$_POST['image']) == $_COOKIE['image'])
     {
      
    //okay to proceed - send email
      
    mail("youraddress@domain.com""[Contact Form]".$_POST['subject'], "Name: ".$_POST['name']."\r\nEmail: ".$_POST['email']."\r\nIP Address: ".$_SERVER['REMOTE_ADDR']."\r\nTime: ".date('n/j/y g:ia')."\r\n---------------\r\nSubject: ".$_POST['subject']."\r\n\r\n".$_POST['body'], "reply-to: ".$_POST['email']);
      
    header('location: contact_success.html');
     }
     else
     {
      
    //incorrect
      
    $error "Sorry, you did not enter the correct image!<br />";
     }
    }
    //generate image
    $captchakey hash('crc32'rand().rand().time().time().$_SERVER['remote_addr']);
    $captchakey str_replace("0"""$captchakey);
    setcookie('image'hash('ripemd128'$captchakey));
    ob_start();
    define("WIDTH"250);
    define("HEIGHT"57);
    define("F_SIZE"15);
    define("F_ANGLE"10);
    define("F_TEXT"$captchakey);
    define("F_FONT""rita.ttf");
     
    $img imagecreate(WIDTHHEIGHT);
    $white imagecolorallocate($img255255255);
    $black imagecolorallocate($img000);
    imagerectangle($img00WIDTH-1HEIGHT-1$black);
     
    $box imagettfbbox(F_SIZEF_ANGLEF_FONTF_TEXT);
    $start_x = ((WIDTH/2) - (int)(($box[0] + $box[2] + $box[4] + $box[6])/4))-4;
    $start_y = (HEIGHT/2) - (int)(($box[1] + $box[3] + $box[5] + $box[7])/4);
    imagettftext($imgF_SIZEF_ANGLE$start_x$start_y$blackF_FONT ,F_TEXT);
     
    imagepng($img);
    imagedestroy($img);
    $image_data ob_get_contents();
    ob_end_clean();
    $img base64_encode ($image_data);

    //the image has been generated

    //you can start putting your template after the next line
    ?>

    <form method="POST">
    <input type="hidden" name="action" value="submit" />
    <?php echo @$error?>
    Name: <input name="name"><br />
    Email: <input name="email"><br />
    Message:<br />
    <textarea name="body"></textarea><br />
    <img src="data:image/png;base64,<?php echo $img?>" /><br />
    Enter the text in the image: <input name="image" /><br />
    <input type="submit" />
    </form>
    Oh, and obviously you will have to edit the youraddress@domain.com, and replace it with your email address.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds