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
https://forums.phpfreaks.com/topic/261126-php-form-doesnt-show-up/
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: [email protected]</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('[email protected]', '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>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.