Jump to content

PHP form doesn't show up


jlodwick

Recommended Posts

I'm trying to do a simple PHP form with Securimage Captcha and whenever I add this variable "$securimage = new Securimage();" the page displays nothing.  Could someone please help me with this?  My php file is already in the securimage directory so that's why I'm pointing directly to the file.

18094_.php

Link to comment
Share on other sites

<?php session_start(); ?>

 

<?

$name1 = trim($_POST["name1"]);

$email1 = trim($_POST["email1"]);

?>

 

<?

include_once $_SERVER['DOCUMENT_ROOT'] . 'securimage.php';

$securimage = new Securimage();

?>

 

 

<form action="testing1.php" method="POST" name="subscribe">

<?

 

$submitted = trim($_POST["submit"]);

if ($submitted == "Send")

{

if (($name1 == "") || (!preg_match('/^[a-zA-Z]*$/',$name1)) ||

(!preg_match('/^[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$/',$email1)) ||

($securimage->check($_POST['captcha_code']) == false))

 

{

?>

<p>  

Please fill in the following<br>

<span style='font-family:Verdana; font-size: 9px; color: red;'>( * indicates a required field )</span><br><br>

 

<span style='font-family:Verdana; font-size: 12px; color: red;'><b>There was a problem with your submission. Errors are displayed below in red.</b><br></span>

</p>

 

 

 

 

 

<br>

<span style='font-family:Verdana; font-size: 9px; color: red;'>* </span><strong>Name</strong>

<?

if ($name1 == "" || (!preg_match('/^[a-zA-Z]*$/',$name1)))

{ echo "<span style='font-family:Verdana; font-size: 12px; color: red;'><b>Invalid Name</b> (only letters and dashes - max 999)</span>"; }

?>

<br>

<input type="text" size="22" name="name1" value="<? echo $name1; ?>">

<br>

<br>

<span style='font-family:Verdana; font-size: 9px; color: red;'>* </span><strong>E-mail</strong>

<?

if (!preg_match('/^[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$/',$email1))

{ echo "<span style='font-family:Verdana; font-size: 12px; color: red;'><b>Invalid E-mail.</b> Format example: someone@domain.com</span>"; }

?>

<br>

<input type="text" size="22" name="email1" value="<? echo $email1; ?>">

<br>

<br>

<img id="captcha" src="securimage_show.php" alt="CAPTCHA Image" />

<br>

<br>

<br>

    <object type="application/x-shockwave-flash" data="./securimage_play.swf?audio_file=./securimage_play.php&bgColor1=#fff&bgColor2=#fff&iconColor=#777&borderWidth=1&borderColor=#000" height="32" width="32">

    <param name="movie" value="./securimage_play.swf?audio_file=./securimage_play.php&bgColor1=#fff&bgColor2=#fff&iconColor=#777&borderWidth=1&borderColor=#000">

    </object>

&nbsp

    <a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false"><img src="./images/refresh.png" alt="Reload Image" onclick="this.blur()" align="bottom" border="0"></a><br />

    <strong>Enter Code*:</strong><br />

<?

if ($securimage->check($_POST['captcha_code']) == false)

{ echo "<span style='font-family:Verdana; font-size: 12px; color: red;'><b>The security code entered was incorrect.</b></span><br /><br />";

echo "<span style='font-family:Verdana; font-size: 12px; color: red;'><b>Please go</b></span> <a href='javascript:history.go(-1)'><span style='font-family:Verdana; font-size: 12px; color: red;'><b>back</b></span></a> and try again.";

exit;}

?>   

    <input type="text" name="ct_captcha" size="12" maxlength="8" />

<p>

<INPUT TYPE=submit NAME='submit' VALUE='Send'>

</p>

<?

}

// end - identify errors in data entered

 

// start - if everything entered meets the initial requirements

elseif (($name1 != "") || (preg_match('/^[a-zA-Z]*$/',$name1)) &&

      (preg_match('/^[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$/',$email1)) &&

      ($securimage->check($_POST['captcha_code']) == true))

 

{

//set the random id length

$random_id_length = 10;

 

//generate a random id encrypt it and store it in $rnd_id

$rnd_id = crypt(uniqid(rand(),1));

 

//to remove any slashes that might have come

$rnd_id = strip_tags(stripslashes($rnd_id));

 

//Removing any . or / and reversing the string

$rnd_id = str_replace(".","",$rnd_id);

$rnd_id = strrev(str_replace("/","",$rnd_id));

 

//finally I take the first 10 characters from the $rnd_id

$rnd_id = substr($rnd_id,0,$random_id_length); 

 

 

$message = "\r\n Name: ".$name1."\r\n E-mail: ".$email1;

 

 

// In case any of our lines are larger than 70 characters, we should use wordwrap()

$message = wordwrap($message, 70);

 

$headers = 'From: '.$email1. "\r\n" .

    'Reply-To: '.$email1. "\r\n" .

    'X-Mailer: PHP/' . phpversion();

 

// Send

mail('myemail@hotmail.com', 'Subscribe message from www.spaenvydeals.com', $message, $headers);

 

// the name of the file you're writing to

$myFile = "opt-in-list.txt";

 

// opens the file for appending (file must already exist)

$fh = fopen($myFile, 'a');

 

// Makes a CSV list of your post data

$comma_delmited_list = implode(",", $_POST) . "\n";

 

// Write to the file

fwrite($fh, $comma_delmited_list);

 

// You're done

fclose($fh);

 

 

?>

<SCRIPT LANGUAGE='JavaScript'>

        window.alert('Thank you! Your message has been sent.')

        window.location.href='http://www.spaenvydeals.com/Deals'

        </SCRIPT>;

 

<?

 

}

}

 

if ($submitted != "Send")

{

?>

<p>

Please fill in the following<br>

<span style='font-family:Verdana; font-size: 9px; color: red;'>( * indicates a required field )</span>

<p>

<span style='font-family:Verdana; font-size: 9px; color: red;'>* </span><strong>Name</strong><br><input type="text" size="22" name="name1">

<br>

<br>

<span style='font-family:Verdana; font-size: 9px; color: red;'>* </span><strong>E-mail</strong><br><input type="text" size="22" name="email1">

<br>

<br>

<img id="captcha" src="securimage_show.php" alt="CAPTCHA Image" />

<br>

<br>

<br>

    <object type="application/x-shockwave-flash" data="./securimage_play.swf?audio_file=./securimage_play.php&bgColor1=#fff&bgColor2=#fff&iconColor=#777&borderWidth=1&borderColor=#000" height="32" width="32">

    <param name="movie" value="./securimage_play.swf?audio_file=./securimage_play.php&bgColor1=#fff&bgColor2=#fff&iconColor=#777&borderWidth=1&borderColor=#000">

    </object>

&nbsp

    <a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false"><img src="./images/refresh.png" alt="Reload Image" onclick="this.blur()" align="bottom" border="0"></a><br />

    <strong>Enter Code*:</strong><br />

    <input type="text" name="ct_captcha" size="12" maxlength="8" />

 

  <p>

<INPUT TYPE=submit NAME='submit' VALUE='Send'>

</p>

</form>

<?

}

?>

 

</td>

</table>

 

Link to comment
Share on other sites

If your Securimage file and your PHP file are both in the same folder, try removing the document root from the include path:

 

include_once 'securimage.php';

 

Next time, post your code inside code tags (found in the editor above the smilies).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.