我不斷看到if語句顯示在域http://bambooflooringcapetown.net/recap.php驗證碼與晶麻煩
你可以看到自己的文字。
我想實現Securimage進入我的表單,但有麻煩。
驗證碼我用: http://www.phpcaptcha.org/documentation/quickstart-guide/
目前代碼:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
session_start();
?>
<div>
<?php
require_once 'securimage/securimage.php';
// Code Validation
$image = new Securimage();
if ($image->check($_POST['captcha_code']) == true) {
echo "Correct!";
} else {
echo "Sorry, wrong code.";
}
require_once 'securimage/securimage.php';
echo Securimage::getCaptchaHtml();
?>
</div>
<style>
#newheadform
{
position: relative;
top: -15px;
left: 700px;
width: 280px;
height: 361px;
border: 1px solid #<?php echo $Config['bodyFontColour']; ?>;
background-color: #<?php echo $Config['bodyColour']; ?>;
color: #<?php echo $Config['bodyFontColour']; ?>;
opacity: 0.85;
padding: 10px;
z-index: 100;
font-family: sans-serif;
}
#newheadform input[type=text], #newheadform textarea
{
border: 1px solid #000;
width: 96%;
}
</style>
<!-- NEW ENQUIRY FORM START -->
<form method="post" action="">
<table id="newheadform" cellpadding="5" cellspacing="0">
<tr><th colspan="2" align="center"><font size="5">Email us now</font></th></tr>
<tr><td>Name*:</td><td><input type="text" name="name"/></td></tr>
<tr><td>Phone*:</td><td><input type="text" name="number"/></td></tr>
<tr><td>Email*:</td><td><input type="text" name="email"/></td></tr>
<tr><td colspan="2">Message:</td></tr>
<tr><td colspan="2"><textarea name="message" style="height: 50px;"></textarea></td></tr>
<tr><td colspan="2" align="center">
<input type="text" name="captcha_code" size="10" maxlength="6" />
<a href="#" onclick="document.getElementById('captcha').src = '/securimage/securimage_show.php?' + Math.random(); return false">Different Image</a>
<?php if(isset($_POST['number']))
{
if(empty($_POST['name']) || empty($_POST['number']) || empty($_POST['email']))
echo '<font color="red" size="1"><b>* These fields are compulsory</b></font><br/><br/>';
else
{
$headers='From: '.$_POST['email']."rn";
$headers.='Reply-To: '.$_POST['email']."rn";
$headers.='X-Mailer: PHP/'.phpversion();
$body='You received a contact request from '.$_POST['name'].' ('.$_POST['email'].') on your site '.$domainname."rn";
$body.='Contact number: '.$_POST['number']."rnrn";
if(!empty($_POST['message'])) $body.=$_POST['message'];
if(mail($_SESSION['contact3'],'New Enquiry from '.$domainname,$body,$headers))
echo '<font color="green"><b>Your email has been sent</b></font><br/>';
}
}
?>
<img id="captcha" src="securimage/securimage_show.php" alt="CAPTCHA Image" />
<input type="button" name="send" value="Send"/></td></tr>
</table>
</form>
<!-- NEW ENQUIRY FORM END -->
WITH NO CAPTCHA
<!-- NEW ENQUIRY FORM START -->
<style>
#newheadform
{
position: relative;
top: -15px;
left: 700px;
width: 280px;
height: 361px;
border: 1px solid #<?php echo $Config['bodyFontColour']; ?>;
background-color: #<?php echo $Config['bodyColour']; ?>;
color: #<?php echo $Config['bodyFontColour']; ?>;
opacity: 0.85;
padding: 10px;
z-index: 100;
font-family: sans-serif;
}
#newheadform input[type=text], #newheadform textarea
{
border: 1px solid #000;
width: 96%;
}
</style>
<form method="post" name="newheadformform">
<table id="newheadform" cellpadding="5" cellspacing="0">
<tr><th colspan="2" align="center"><font size="5">Email us now</font></th></tr>
<tr><td>Name*:</td><td><input type="text" name="name"/></td></tr>
<tr><td>Phone*:</td><td><input type="text" name="number"/></td></tr>
<tr><td>Email*:</td><td><input type="text" name="email"/></td></tr>
<tr><td colspan="2">Message:</td></tr>
<tr><td colspan="2"><textarea name="message" style="height: 50px;"></textarea></td></tr>
<tr><td colspan="2" align="center">
<?php if(isset($_POST['number']))
{
if(empty($_POST['name']) || empty($_POST['number']) || empty($_POST['email']))
echo '<font color="red" size="1"><b>* These fields are compulsory</b></font><br/><br/>';
else
{
$headers='From: '.$_POST['email']."rn";
$headers.='Reply-To: '.$_POST['email']."rn";
$headers.='X-Mailer: PHP/'.phpversion();
$body='You received a contact request from '.$_POST['name'].' ('.$_POST['email'].') on your site '.$domainname."rn";
$body.='Contact number: '.$_POST['number']."rnrn";
if(!empty($_POST['message'])) $body.=$_POST['message'];
if(mail($_SESSION['contact3'],'New Enquiry from '.$domainname,$body,$headers))
echo '<font color="green"><b>Your email has been sent</b></font><br/>';
}
}
else echo '<font size="1">* Compulsory</font><br/><br/>'; ?>
Calculate*: <span id="num1"></span> + <span id="num2"></span> <input type="number" name="calculate" placeholder="" /><br><br>
<input type="button" name="send" value="Send"/></td></tr>
</table>
</form>
<script type="text/javascript">
$(document).ready(function(e) {
var number1 = Math.floor(Math.random()*12)+1;
var number2 = Math.floor(Math.random()*12)+1;
$('#num1').append(number1);
$('#num2').append(number2);
$('input[name=send]').click(function(){
var total = number1 + number2;
var answer = $('input[name=calculate]').val();
if(total !== parseInt(answer)){
alert("Please enter the correct calculation to send your enquiry.");
} else {
document.newheadformform.submit();
return false;
}
});
});
</script>
<!-- NEW ENQUIRY FORM END -->
旁註:您正在將CSS/HTML與PHP混合使用。將它們分開。 –
你的PHP必須用'<?php'標籤包裝。但就像@ Fred-ii-說,如果PHP在另一個文件 – Cfreak
會更好,他們會分裂他們嗎?因爲它都來自index.php – Pixel