Help with feedback form

This is a discussion on "Help with feedback form" within the PHP Forum section. This forum, and the thread "Help with feedback form are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jul 26th, 2006, 18:03
AdRock's Avatar
SuperMember

SuperMember
Join Date: Jul 2006
Location: Devon, England
Posts: 565
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to AdRock
Help with feedback form

I have a feedback form which also has a captcha image on it so when the user sub,its some feedbcak they have to enter the text from the captcha image.

If the user enters all fields and the captcha correctly the email is sent. If the user doesn't enter the captcha correctly the form is reloaded but if the user misses any feilds and enters the captcha correctly a blank email is sent and an error message is displayed
Warning: Cannot modify header information - headers already sent by (output started at /home/adrock/public_html/jack/includes/captcha.php:24) in /home/adrock/public_html/jack/includes/captcha.php on line 51

How do I add some validation so that the email is not sent unless all fields are filled?

This is the code for the feedback form

Code: Select all
 
<form method="POST" action="includes/captcha.php">
<!-- DO NOT change ANY of the php sections -->
<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>
<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />
<p class="style3"><label for="name"><b>Name:</b></label> <input type="text" name="visitor" size="30" /></p>
<p class="style3"><label for="e-mail"><b>E-mail:</b></label> <input type="text" name="visitormail" size="30" /></p>
<p class="style3"><label for="notes"><b>Comments:</b></label><textarea name="notes" rows="10" cols="30"></textarea></p><br>
<p class="style3"><b>Please enter the text you see in the black box</b></p>
<img src="includes/captcha_image.php" style="padding-left:75px;" />
<p class="style3" style="padding-left:75px;"><input type="text" name="captcha_input" size="12" style="width:95px;"></p>
 
<input type="submit" id="scratch_submit" value="Submit Feedback" class="submit-button" />
</form>
This is the code for captcha.php
PHP: Select all

<?
// *** The CAPTCHA comparison - http://frikk.tk ***
session_start();
// *** We need to make sure theyre coming from a posted form -
// If not, quit now ***
if ($_SERVER["REQUEST_METHOD"] <> "POST")
die(
"You can only reach this page by posting from the html form");
// *** The text input will come in through the variable $_POST["captcha_input"],
// while the correct answer is stored in the cookie $_COOKIE["pass"] ***
if ($_POST["captcha_input"] == $_SESSION["pass"])
{
$myemail "me@mysite.co.uk"
$ccx ""
if(!
$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) 
{
echo 
"<h2>Use Back - Enter valid e-mail</h2>\n"
$badinput "<h2>Feedback was NOT submitted</h2>\n";
}
if(empty(
$visitor) || empty($visitormail) || empty($notes )) {
echo 
"<h2>Use Back - fill in all fields</h2>\n";
}
echo 
$badinput;
$todayis date("l, F j, Y, g:i a") ;
$subject $attn
$notes stripcslashes($notes); 
$message " $todayis [EST] \n
Message: $notes \n 
From: $visitor ($visitormail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
"
;
$from "From: $visitormail\r\n";
if ((
$ccopy == "ccyes") && ($visitormail != "")) 
mail($visitormail$subject$message$from);
if (
$myemail != ""
mail($myemail$subject$message$from);
if (
$ccx != ""
mail($ccx$subject$message$from);
header('Location: http://www.mysite.co.uk/jack/index.php?page=thankyou');
}
else 
{
header('Location: http://www.mysite.co.uk/jack/index.php?page=contact');
}
?>
Is there a way that I can resubmit the form with a message about which field to put in instead of opening a new page?

Last edited by AdRock; Jul 26th, 2006 at 18:04. Reason: html tags too large
Reply With Quote

  #2 (permalink)  
Old Jul 26th, 2006, 23:05
Most Reputable Member
Join Date: Aug 2005
Location: North Wales, United Kingdom
Age: 21
Posts: 1,093
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to sypher
Re: Help with feedback form

Change your submit button's value to submit, then use the following php.
PHP: Select all

if (isset($_POST['submit'])) {
//all your php code here
}
else {
echo 
the form here;

This way the form and php that process's it is all contained in one .php file.
Remember to change the forms action to the .php file your going to be naming this to.
Reply With Quote
  #3 (permalink)  
Old Jul 27th, 2006, 01:06
AdRock's Avatar
SuperMember

SuperMember
Join Date: Jul 2006
Location: Devon, England
Posts: 565
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to AdRock
Re: Help with feedback form

Right......I have found a script that does exaxtly what I want but i want to add captcha to the form.

I know how to display the image but how do I use the session variable generated by the captcha image with the form validation so the message is only sent if all fields are entered and the captcha code is correct.

I have attached both the feedback form and the captcha image generator script.

I'm sure it's just comparing the sessions but |i don't know how to do it

Many thanks
Attached Files
File Type: txt captcha.txt (1.5 KB, 37 views)
File Type: txt contact.txt (2.7 KB, 39 views)
Reply With Quote
Reply

Tags
help, feedback, form

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Another bit of feedback. craig Webforumz Suggestions and Feedback 5 Dec 19th, 2006 21:14
how to send filled feedback form reeta.vadgama Web Page Design 5 Jul 24th, 2006 23:23
Need help with feedback form >< papusska Web Page Design 1 Apr 19th, 2006 16:21
ASP feedback form Paul Wayrider Classic ASP 2 Feb 12th, 2004 19:29


All times are GMT. The time now is 02:14.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43