...

View Full Version : newbie - help with recaptcha



quartzy
12-12-2010, 01:21 AM
I have a recapture form in php. And I have a form, I have tried to integrate the two but I have no idea. This is the code I have, am I doing anything wrong? I cant see how the form would be sent via email.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<title>Volunteering Form</title>
<link href="styles/layout.css" rel="stylesheet" type="text/css" />
<link href="styles/mainstyle.css" rel="stylesheet" type="text/css" />
<link href="styles/form.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container">
<div id="header">
<div id="left_header"><h1 id="logo"><a href=" title="Lee Oasis Furniture Project"><em title="Lee Oasis Home Page"></em>Lee Oasis Furniture Project</a></h1>
</div><!--left_header-->
<div id="right_header">
<p class="logtitle">Recycle and donate<br />unwanted furniture<br/>Tel: 020 8857
0043<br /><span class="caps">Lewisham Area</span></p></div><!--right_header-->
</div><!--header-->
<div class="clear"></div><!--clear-->
<div id="nav">
<ul>
<li><a href="../index.html">Home</a></li>
<li><a href="../about.html">About Us</a></li>
<li><a href="../dropin.html">Drop-in</a></li>
<li><a href="../furniture.html">Furniture Project</a></li>
<li class="current"><a href="../volunteer.html">Volunteer</a></li>
<li><a href="../news.html">News/Events</a></li>
<li id="last"><a href="../appeals.html">Appeals</a></li>
</ul>
</div><!--nav-->
<div class="textbox_outer">
<div class="textbox_inner">
<h2>Volunteer</h2>
<!-- the body tag is required or the CAPTCHA may not show on some browsers -->
<div id="form">
<form action="mailto:" method="POST" enctype="multipart/form-data" name="form_to_email">
<p><label>Your Name:</label><br />
<input type="text" size="20" name="name" /><br />
<label>Your Address:</label><br />
<textarea name="address" rows="5" cols="20">
</textarea><br /></p>
<p><label>Telephone:</label><br />
<input type="text" size="20" name="telephone" /><br /><br />
<label>Email:</label><br />
<input type="text" size="20" name="email" /><br /><br />
<label>What would you like to do/skills offered:</label><br />
<textarea name="skills" rows="5" cols="20">
</textarea></p>
<p>How much time do you have available?<br />
<label>Hours per week/month?</label><br />
<input type="text" size="20" name="time" /><br /><br />
<label>On Occassional Basis?</label><br />
<input type="text" size="20" name="occassional" /></p>
<p>I understand the general policy of Lee Oasis and agree with its aims and
ethos. I have also read the relevant Health and Safety and/or Child Protection
Policy as it applies to me; and agree to abide by it.</p>
<p><label>Signed (Add name and submit form):</label>
<input type="text" size="20" name="signed" /><br /><br />
<label>Date:</label><br/>
<input type="text" size="20" name="date" /><br /><br />
<input type="submit" value="email_form" /></p>
</form>
<form method="post" action="../php/verify.php">
<?php
require_once('recaptchalib.php');
$publickey = "(removed for this post) "; // you got this from the signup page
echo recaptcha_get_html($publickey);
?>
<script type="text/javascript">
var RecaptchaOptions = {
theme : 'clean'
};
</script>
<input type="submit" />
</form>
</div><!--textbox_inner-->
</div><!--textbox_outer-->
<div class="clear"></div><!--cleardiv-->
<div id="footer">
<p></p>
</div><!--footer-->
</div><!--container-->
</body>
</html>

I know it is a mess where do I begin, I have read all the documentation but it is not very helpful to me. This is a php page, and it is not even showing my styles.

mlseim
12-12-2010, 02:35 AM
wow ... that is a mess (trying hard not to lol on you).

ReCaptcha doesn't process and send forms. It only checks for the proper code.

Here is what I suggest ...

Start over.

1) Create your contact page with the form. Just the contact page and the form.
Don't worry about the Recaptcha yet.

2) Create the PHP script that processes the form. Make that a separate script.
Right now you have form action="mailto:" . You will need
a PHP script to process your contact form. I'm not sure if you have that yet?
Don't combine the form with the script that processes it, make it separate.
Again, don't worry about the Recaptcha yet.

3) Get your form working, and the PHP script working. So when you fill out the
form, it successfully emails it. Make it all look and work the way you want.
Leave some room at the bottom of your form for the "future Recaptcha" ...

THEN, .... THEN, you can insert Recaptcha. When you get to that point,
give us the link to your form, and list your PHP script that processes the form.
It will be easier to insert Recaptcha at that time.

quartzy
12-12-2010, 12:11 PM
OK I will get on with creating the form and getting it to work without the captcha, but where would I get some code to process the form?

mlseim
12-12-2010, 06:49 PM
The script below is from another post.
You will use the variable names from your contact form,
and your own email address.



<?php

// This is a super basic mail form without any
// validation, captcha, or checking of any kind.

// Get variables from your form ...
$firstname = $_POST['Fname'];
$lastname = $_POST['Lname'];
$usercity = $_POST['UseCity'];
$usercountry = $_POST['UserCountry'];
$useremail = $_POST['userEmail'];
$username = $_POST['Username'];
$userpassword = $_POST['Userpassword'];
$fmessage = $_POST['Message'];

// Who the form gets sent to ...
$recipient = "youremail@hotmail.com";
$subject = "Your Webpage Contact Form";

// Where to go after the user submits the form ...
$redirect = "index.html";

$message = "
================================
Name: $firstname $lastname
User: $username
Email: $useremail
-----------------------------------------
$fmessage
================================
";

$extraheaders = "From: $useremail\n\nReply-To: $useremail\n\n";

if (! mail($recipient, $subject, $message, $extraheaders))
echo "Mail did not send for some reason.";

header("Location: ".$redirect);

?>

quartzy
12-15-2010, 11:22 PM
Thanks for posting this script but what do I do with it?

<?php

// This is a super basic mail form without any // validation, captcha, or checking of any kind.

// Get variables from your form ...
$firstname = $_POST['Fname'];
$lastname = $_POST['Lname'];
$usercity = $_POST['UseCity'];
$usercountry = $_POST['UserCountry'];
$useremail = $_POST['userEmail'];
$username = $_POST['Username'];
$userpassword = $_POST['Userpassword']; $fmessage = $_POST['Message'];

// Who the form gets sent to ...
$recipient = "myemail";
$subject = "Volunteering Form.html";

// Where to go after the user submits the form ...
$redirect = "thanks.html";

$message = "
================================
Name: $firstname $lastname
User: $username
Email: $useremail
-----------------------------------------
$fmessage
================================
";

$extraheaders = "From: $useremail\n\nReply-To: $useremail\n\n";

if (! mail($recipient, $subject, $message, $extraheaders))
echo "Mail did not send for some reason.";

header("Location: ".$redirect);

?>


What I mean is how do I call it on the volunteering form. I have this right now, <form action="mailto:" method="POST" enctype="multipart/form-data" name="form_to_email"> I have called this php above process.php so how do I call it?

thanks

mlseim
12-15-2010, 11:41 PM
<form action="process.php" method="POST" enctype="multipart/form-data" name="form_to_email">

Then, you have to look at your <form> variable names ... eg. name="Email",
and make them the same in "process.php" as in your <form>

Using Google to find some "php contact form tutorials" might be beneficial.

quartzy
12-15-2010, 11:56 PM
How will I know what the variables are until the form is filled in? OK I understand that will take me some time, I have looked for php forms but I dont know if google has any that I can find.

quartzy
12-16-2010, 01:30 AM
thanks for helping me, but for the variables should I add user to them all?

$username = $_POST['name'];

I just have 'name' as the named field and not username

quartzy
12-16-2010, 01:38 AM
I now have this: Is it correct?


<?php

// This is a super basic mail form without any // validation, captcha, or checking of any kind.

// Get variables from your form ...
$username = $_POST['name'];
$useraddress = $_POST['address'];
$useremail = $_POST['email'];
$usertelephone = $_POST['telephone'];
$userskills = $_POST['skills'];
$usertime = $_POST['time'];
$useroccassional = $_POST['occassional'];
$usersignature = $_POST['signature'];
$userdate = $_POST['date'];

// Who the form gets sent to ...
$recipient = "my email address";
$subject = "Volunteering Form";

// Where to go after the user submits the form ...
$redirect = "thanks.html";

$message = "Thank-you for your completed form, you will hear from us soon.
================================
Name: $name
Email: $useremail
-----------------------------------------
$fmessage
================================
";

$extraheaders = "From: $useremail\n\nReply-To: $useremail\n\n";

if (! mail($recipient, $subject, $message, $extraheaders))
echo "Mail did not send for some reason.";

header("Location: ".$redirect);

?>

mlseim
12-16-2010, 03:12 AM
I don't know ... try it.

Put your real email address in this line:
$recipient = "my email address";

and see if you get an email when you submit the form.

quartzy
12-16-2010, 12:33 PM
The form did produce an email, but the form is not recognising my thanks.html page. It think that the thanks.html should be in the php_files folder. So how can I make the below into a php page?



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Language" content="en-gb" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<title>Volunteering Form</title>
<link href="styles/layout.css" rel="stylesheet" type="text/css" />
<link href="styles/mainstyle.css" rel="stylesheet" type="text/css" />
<link href="styles/form.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container">
<div id="header">
<div id="left_header"><h1 id="logo"><a href=" title="Lee Oasis Furniture Project"><em title="Lee Oasis Home Page"></em>Lee Oasis Furniture Project</a></h1>
</div><!--left_header-->
<div id="right_header">
<p class="logtitle">Recycle and donate<br />unwanted furniture<br/>Tel: 020 8857
0043<br /><span class="caps">Lewisham Area</span></p></div><!--right_header-->
</div><!--header-->
<div class="clear"></div><!--clear-->
<div id="nav"><a id="top"></a>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About Us</a></li>
<li><a href="dropin.html">Drop-in</a></li>
<li><a href="furniture.html">Furniture Project</a></li>
<li class="current"><a href="volunteer.html">Volunteer</a></li>
<li><a href="news.html">News/Events</a></li>
<li id="last"><a href="appeals.html">Appeals</a></li>
</ul>
</div><!--nav-->
<div class="textbox_outer">
<div class="textbox_inner">
<h2>Volunteering Form</h2>
<p>Thank you for your interest and completion of form, you will hear from us soon.</p><br /><br />
<p><img alt="arrow left icon image" height="11" src="images/arrow_left.jpg" width="14" />
<a href="volunteer.html">Back</a> to volunteer page</p>
<div class="empty"></div>
</div><!--textbox_inner-->
</div><!--textbox_outer-->
<div class="clear"></div><!--cleardiv-->
<div id="footer"><p><br /><span class="smaller">Registered Charity No. </span></p></div><!--footer-->
</div><!--container-->
</body>
</html>



DO I just add <?php to the beginning of the page?

mlseim
12-16-2010, 02:21 PM
Your "thanks.html" file is just a webpage you make that says "thank you".
It can be located anywhere, you just have to provide the path to it here ...

// Where to go after the user submits the form ...
$redirect = "thanks.html";

What is the link to your "thanks.html" page?

When everything works perfectly, you get the email you want,
the thanks page works, everything looks good ... let me know.

Then, post your contact form and your process.php form once again.
It's at that point where we will be adding the captcha portion.

quartzy
12-16-2010, 04:25 PM
Silly me, of course it would recognise the path name. It goes to thanks.html now.

I have another problem though the form is not picking up the workhours field. DO you know why?


<?php

// This is a super basic mail form without any // validation, captcha, or checking of any kind.

// Get variables from your form ...
$username = $_POST['name'];
$useraddress = $_POST['address'];
$useremail = $_POST['email'];
$usertelephone = $_POST['telephone'];
$userskills = $_POST['skills'];
$userworkhours = $_POST['workhours'];
$useroccassional = $_POST['occassional'];
$usersigned = $_POST['signed'];
$userdate = $_POST['date'];

// Who the form gets sent to ...
$recipient = "<E-mail Removed as User\'s Request>";
$subject = "Volunteering Form";

// Where to go after the user submits the form ...
$redirect = "../thanks.html";

$message = "
================================
Name: $username
Address: $useraddress
Email: $useremail
Telephone: $usertelephone
Skills: $userskills
Workhours: $userworkhours
Occassional: $useroccassional
Signed: $usersigned
Todaydate: $userdate

-----------------------------------------
$fmessage
================================
";

$extraheaders = "From: $useremail\n\nReply-To: $useremail\n\n";

if (! mail($recipient, $subject, $message, $extraheaders))
echo "Mail did not send for some reason.";

header("Location: ".$redirect);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Volunteer Form Process</title>
</head>

<body>

</body>

</html>

mlseim
12-16-2010, 04:33 PM
Look at your form:

<p>How much time do you have available?<br />
<label>Hours per week/month?</label><br />
<input type="text" size="20" name="time" /><br /><br />

I don't see "workhours" anywhere on your form.

quartzy
12-16-2010, 08:46 PM
Will time work? as I changed time to workhours, because 'time' - was showing up as green in the php editor, so there must be something wrong with 'time'. Wht od you think?

quartzy
12-16-2010, 09:01 PM
I've changed the name to workhours, now I have the ocmpleted form here is the php
<?php

// This is a super basic mail form without any // validation, captcha, or checking of any kind.

// Get variables from your form ...
$username = $_POST['name'];
$useraddress = $_POST['address'];
$useremail = $_POST['email'];
$usertelephone = $_POST['telephone'];
$userskills = $_POST['skills'];
$userhours = $_POST['hours'];
$useroccassional = $_POST['occassional'];
$usersigned = $_POST['signed'];
$userdate = $_POST['date'];

// Who the form gets sent to ...
$recipient = "";
$subject = "Volunteering Form";

// Where to go after the user submits the form ...
$redirect = "../thanks.html";

$message = "
================================
Name: $username
Address: $useraddress
Email: $useremail
Telephone: $usertelephone
Skills: $userskills
Hours: $userhours
Occassional: $useroccassional
Signed: $usersigned
Todaydate: $userdate

-----------------------------------------
$fmessage
================================
";

$extraheaders = "From: $useremail\n\nReply-To: $useremail\n\n";

if (! mail($recipient, $subject, $message, $extraheaders))
echo "Mail did not send for some reason.";

header("Location: ".$redirect);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Volunteer Form Process</title>
</head>

<body>

</body>

</html>


and the html


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Language" content="en-gb" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<title>Volunteering Form</title>
<link href="styles/layout.css" rel="stylesheet" type="text/css" />
<link href="styles/mainstyle.css" rel="stylesheet" type="text/css" />
<link href="styles/form.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container">
<div id="header">
<div id="left_header"><h1 id="logo"><a href="" title="Lee Oasis Furniture Project"><em title="Lee Oasis Home Page"></em>Lee Oasis Furniture Project</a></h1>
</div><!--left_header-->
<div id="right_header">
<p class="logtitle">Recycle and donate<br />unwanted furniture<br/>Tel: 020 8857
0043<br /><span class="caps">Lewisham Area</span></p></div><!--right_header-->
</div><!--header-->
<div class="clear"></div><!--clear-->
<div id="nav"><a id="top"></a>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About Us</a></li>
<li><a href="dropin.html">Drop-in</a></li>
<li><a href="furniture.html">Furniture Project</a></li>
<li class="current"><a href="volunteer.html">Volunteer</a></li>
<li><a href="news.html">News/Events</a></li>
<li id="last"><a href="appeals.html">Appeals</a></li>
</ul>
</div><!--nav-->
<div class="textbox_outer">
<div class="textbox_inner">
<h2>Volunteering Form</h2>
<form class="volunteering" action="php_files/process.php" method="post" enctype="multipart/form-data" name="form_to_email">
<fieldset><legend>Details</legend><p><label id="name"><span>Name:</span></label><input type="text" size="30" name="name" /></p>
<p><label id="address"><span>Address:</span></label><textarea name="address" rows="5" cols="30"></textarea></p>
<p><label id="email"><span>Email:</span></label><input type="text" size="30" name="email" /></p>
<p><label id="telephone"><span>Telephone:</span></label><input type="text" size="30" name="telephone" /></p></fieldset>
<fieldset><legend>Skills and Time</legend><p><label id="skills"><span>What would you like to do/skills offered:</span></label><textarea name="skills" rows="5" cols="30"></textarea></p>
<p>How much time do you have available?</p>
<p><label id="hours"><span>Hours per week/month?</span></label><input type="text" size="30" name="hours" /></p>
<p><label id="occassional"><span>On Occassional Basis?</span></label><input type="text" size="30" name="occassional" /></p></fieldset><br />
<p class="formtext">I understand the general policy of Lee Oasis and agree with its aims and ethos. I have also read the relevant
<a href="pdf-files/Drivers%20health%20and%20safety%20and%20child%20protection.pdf">Health and Safety</a> and/or
<a href="pdf-files/Drop%20In%20Child%20Protection%20and%20Health%20and%20Safety.pdf">Child Protection Policy</a> as it applies to me; and agree to abide by it.</p><br />
<fieldset><legend>Sign and Date</legend><p><label id="signature"><span>Signed (Add name and submit form):</span></label><input type="text" size="30" name="signed" /></p>
<p><label id="date"><span>Date:</span></label><input type="text" size="30" name="date" /></p></fieldset>
<p><input class="submit" type="submit" value="Submit" id="submit" name="submit"/></p></form>
<p class="right"><img alt="arrow up icon image" height="14" src="images/arrow_up.jpg" width="11" /> <a href="#top">Top</a></p>
</div><!--textbox_inner-->
</div><!--textbox_outer-->
<div class="clear"></div><!--cleardiv-->
<div id="footer">
</div><!--footer-->
</div><!--container-->
</body>
</html>

For the captcha I have verify and form_script to call the verify but no idea on how to call it in the html

mlseim
12-16-2010, 09:52 PM
For recaptcha, we'll do it in a few parts ....

Part 1:
I assume you already created a recaptcha account.
So, download the file they require: recaptchalib.php
and upload it into the same directory as your contact form script.

You didn't tell me the name of your contact form script, and whether or
not it's located in the same directory as "process.php" ... so I'm blind to what you did.

Then, your form script will be this ...
You didn't tell me the name of this script ... I assume you call it: "contact.php" ?
Don't forget to put in your public key where it says it should go ...


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Language" content="en-gb" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<title>Volunteering Form</title>
<link href="styles/layout.css" rel="stylesheet" type="text/css" />
<link href="styles/mainstyle.css" rel="stylesheet" type="text/css" />
<link href="styles/form.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container">
<div id="header">
<div id="left_header"><h1 id="logo"><a href="" title="Lee Oasis Furniture Project"><em title="Lee Oasis Home Page"></em>Lee Oasis Furniture Project</a></h1>
</div><!--left_header-->
<div id="right_header">
<p class="logtitle">Recycle and donate<br />unwanted furniture<br/>Tel: 020 8857
0043<br /><span class="caps">Lewisham Area</span></p></div><!--right_header-->
</div><!--header-->
<div class="clear"></div><!--clear-->
<div id="nav"><a id="top"></a>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About Us</a></li>
<li><a href="dropin.html">Drop-in</a></li>
<li><a href="furniture.html">Furniture Project</a></li>
<li class="current"><a href="volunteer.html">Volunteer</a></li>
<li><a href="news.html">News/Events</a></li>
<li id="last"><a href="appeals.html">Appeals</a></li>
</ul>
</div><!--nav-->
<div class="textbox_outer">
<div class="textbox_inner">
<h2>Volunteering Form</h2>
<form class="volunteering" action="php_files/process.php" method="post" enctype="multipart/form-data" name="form_to_email">
<fieldset><legend>Details</legend><p><label id="name"><span>Name:</span></label><input type="text" size="30" name="name" /></p>
<p><label id="address"><span>Address:</span></label><textarea name="address" rows="5" cols="30"></textarea></p>
<p><label id="email"><span>Email:</span></label><input type="text" size="30" name="email" /></p>
<p><label id="telephone"><span>Telephone:</span></label><input type="text" size="30" name="telephone" /></p></fieldset>
<fieldset><legend>Skills and Time</legend><p><label id="skills"><span>What would you like to do/skills offered:</span></label><textarea name="skills" rows="5" cols="30"></textarea></p>
<p>How much time do you have available?</p>
<p><label id="hours"><span>Hours per week/month?</span></label><input type="text" size="30" name="hours" /></p>
<p><label id="occassional"><span>On Occassional Basis?</span></label><input type="text" size="30" name="occassional" /></p></fieldset><br />
<p class="formtext">I understand the general policy of Lee Oasis and agree with its aims and ethos. I have also read the relevant
<a href="pdf-files/Drivers%20health%20and%20safety%20and%20child%20protection.pdf">Health and Safety</a> and/or
<a href="pdf-files/Drop%20In%20Child%20Protection%20and%20Health%20and%20Safety.pdf">Child Protection Policy</a> as it applies to me; and agree to abide by it.</p><br />
<fieldset><legend>Sign and Date</legend><p><label id="signature"><span>Signed (Add name and submit form):</span></label><input type="text" size="30" name="signed" /></p>
<p>
<?php
require_once('recaptchalib.php');
$publickey = "your_public_key"; // you got this from the signup page
echo recaptcha_get_html($publickey);
?>
</p>
<p><label id="date"><span>Date:</span></label><input type="text" size="30" name="date" /></p></fieldset>
<p><input class="submit" type="submit" value="Submit" id="submit" name="submit"/></p></form>
<p class="right"><img alt="arrow up icon image" height="14" src="images/arrow_up.jpg" width="11" /> <a href="#top">Top</a></p>
</div><!--textbox_inner-->
</div><!--textbox_outer-->
<div class="clear"></div><!--cleardiv-->
<div id="footer">
</div><!--footer-->
</div><!--container-->
</body>
</html>



PART 2:
Now, you have to add some scripting to your "process.php" script.

"process.php" ...


<?php
session_start();

// I think your contact form and this script are in two different directories ...
// so, I am blindly adjusting the path to recaptchalib.php ...

require_once('../recaptchalib.php');
$privatekey = "your_private_key";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);

// Get variables from your form ...
$username = $_POST['name'];
$useraddress = $_POST['address'];
$useremail = $_POST['email'];
$usertelephone = $_POST['telephone'];
$userskills = $_POST['skills'];
$userhours = $_POST['hours'];
$useroccassional = $_POST['occassional'];
$usersigned = $_POST['signed'];
$userdate = $_POST['date'];

// Who the form gets sent to ...
$recipient = "";
$subject = "Volunteering Form";

// Where to go after the user submits the form ...
$redirect = "../thanks.html";

// This tests whether or not the code was correct.
// For now, we are just going to return to the form ... wherever that is ...
// If this works, we will revisit this and use PHP SESSION to remember
// what the user entered on the form. For now, we just do this.

if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly ...
header("Location: http://www.yoursite.com/contact.php");
} else {
// Successful captcha, so continue on with the email ...
}

$message = "
================================
Name: $username
Address: $useraddress
Email: $useremail
Telephone: $usertelephone
Skills: $userskills
Hours: $userhours
Occassional: $useroccassional
Signed: $usersigned
Todaydate: $userdate

-----------------------------------------
$fmessage
================================
";

$extraheaders = "From: $useremail\n\nReply-To: $useremail\n\n";

if (! mail($recipient, $subject, $message, $extraheaders))
echo "Mail did not send for some reason.";

header("Location: ".$redirect);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Volunteer Form Process</title>
</head>

<body>

</body>

</html>

quartzy
12-16-2010, 11:20 PM
The page where my form is is called volunteer_form.html so how would I make it a working php page? and turn it into volunteer_form.php ie turn it into a php page, other than renaming it.

This is what my process php page looks like now.
<?php
session_start();
require_once('recaptchalib.php');
$privatekey = "6LeMh78SAAAAANzx07smXAxdMJ2eakdZsz3rdXLV ";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);

// Get variables from your form ...
$username = $_POST['name'];
$useraddress = $_POST['address'];
$useremail = $_POST['email'];
$usertelephone = $_POST['telephone'];
$userskills = $_POST['skills'];
$userhours = $_POST['hours'];
$useroccassional = $_POST['occassional'];
$usersigned = $_POST['signed'];
$userdate = $_POST['date'];

// Who the form gets sent to ...
$recipient = "my email";
$subject = "Volunteering Form";

// Where to go after the user submits the form ...
$redirect = "../thanks.html";

if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly ...
header("Location: http://www.leeoasis.org.uk/contact.php");
} else {
// Successful captcha, so continue on with the email ...
}

$message = "
================================
Name: $username
Address: $useraddress
Email: $useremail
Telephone: $usertelephone
Skills: $userskills
Hours: $userhours
Occassional: $useroccassional
Signed: $usersigned
Todaydate: $userdate

-----------------------------------------
$fmessage
================================
";

$extraheaders = "From: $useremail\n\nReply-To: $useremail\n\n";

if (! mail($recipient, $subject, $message, $extraheaders))
echo "Mail did not send for some reason.";

header("Location: ".$redirect);

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Volunteer Form Process</title>
</head>

<body>

</body>

</html>

mlseim
12-17-2010, 12:18 AM
Just change the extension to .php

You'll have to adjust that in all of your links to that page ...
where links appear on other pages.

And also ...

This line:
header("Location: http://www.leeoasis.org.uk/contact.php");

Will be:
header("Location: http://www.leeoasis.org.uk/volunteer_form.php");




.

quartzy
12-17-2010, 12:30 AM
thanks I have done all that now. How can I test the form there is no submit button or the script that does not show.
www.leeoasis.org.uk/php_files/volunteer_form.php

Inigoesdr
12-17-2010, 02:10 AM
thanks I have done all that now. How can I test the form there is no submit button or the script that does not show.
www.leeoasis.org.uk/php_files/volunteer_form.php

Add one. This is really basic stuff you should be researching yourself.

<input type="submit" name="submit" value="Send" />

mlseim
12-17-2010, 02:11 AM
can you give us a link to your actual contact form?

Using this forum to write and test this is almost impossible.
I should have never even started ... to lead you on and not
be able to test anything out. Do you know anyone who can
actually go into your website files and help you out.

There's just no way to test anything using this forum.

quartzy
12-17-2010, 08:57 AM
I just placed the link on my previoous post, I really appreciate you helping me out, please dont say you should never have started. As to the moderator saying I should do basic stuff myself, he has obviously misunderstood my post. What are the forums for if not to help people?

Of course I know how to add a submit button, that was not my question

mlseim
12-17-2010, 12:27 PM
We're on page 2, post #24 now ...
I just feel like I'm dragging you down. You could have gotten your project done
by now if someone helped you in person ... not using this forum.

=====================

You must not have copied the script below correctly, or you left-out your
public key ... where it's supposed to go in the code below.

Re-copy and re-paste the WHOLE thing, and put in your real public key.

If you have your form and your "process.php" script in two different directories,
you have to provide correct paths to everything ... such as 'recaptchalib.php'

I suggest you put your contact form and process.php and recaptchalib.php all
in the same directory, because I suspect your paths are wrong.




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Language" content="en-gb" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<title>Volunteering Form</title>
<link href="styles/layout.css" rel="stylesheet" type="text/css" />
<link href="styles/mainstyle.css" rel="stylesheet" type="text/css" />
<link href="styles/form.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container">
<div id="header">
<div id="left_header"><h1 id="logo"><a href="" title="Lee Oasis Furniture Project"><em title="Lee Oasis Home Page"></em>Lee Oasis Furniture Project</a></h1>
</div><!--left_header-->
<div id="right_header">
<p class="logtitle">Recycle and donate<br />unwanted furniture<br/>Tel: 020 8857
0043<br /><span class="caps">Lewisham Area</span></p></div><!--right_header-->
</div><!--header-->
<div class="clear"></div><!--clear-->
<div id="nav"><a id="top"></a>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About Us</a></li>
<li><a href="dropin.html">Drop-in</a></li>
<li><a href="furniture.html">Furniture Project</a></li>
<li class="current"><a href="volunteer.html">Volunteer</a></li>
<li><a href="news.html">News/Events</a></li>
<li id="last"><a href="appeals.html">Appeals</a></li>
</ul>
</div><!--nav-->
<div class="textbox_outer">
<div class="textbox_inner">
<h2>Volunteering Form</h2>
<form class="volunteering" action="php_files/process.php" method="post" enctype="multipart/form-data" name="form_to_email">
<fieldset><legend>Details</legend><p><label id="name"><span>Name:</span></label><input type="text" size="30" name="name" /></p>
<p><label id="address"><span>Address:</span></label><textarea name="address" rows="5" cols="30"></textarea></p>
<p><label id="email"><span>Email:</span></label><input type="text" size="30" name="email" /></p>
<p><label id="telephone"><span>Telephone:</span></label><input type="text" size="30" name="telephone" /></p></fieldset>
<fieldset><legend>Skills and Time</legend><p><label id="skills"><span>What would you like to do/skills offered:</span></label><textarea name="skills" rows="5" cols="30"></textarea></p>
<p>How much time do you have available?</p>
<p><label id="hours"><span>Hours per week/month?</span></label><input type="text" size="30" name="hours" /></p>
<p><label id="occassional"><span>On Occassional Basis?</span></label><input type="text" size="30" name="occassional" /></p></fieldset><br />
<p class="formtext">I understand the general policy of Lee Oasis and agree with its aims and ethos. I have also read the relevant
<a href="pdf-files/Drivers%20health%20and%20safety%20and%20child%20protection.pdf">Health and Safety</a> and/or
<a href="pdf-files/Drop%20In%20Child%20Protection%20and%20Health%20and%20Safety.pdf">Child Protection Policy</a> as it applies to me; and agree to abide by it.</p><br />
<fieldset><legend>Sign and Date</legend><p><label id="signature"><span>Signed (Add name and submit form):</span></label><input type="text" size="30" name="signed" /></p>
<p><label id="date"><span>Date:</span></label><input type="text" size="30" name="date" /></p></fieldset>
<p>
<?php
require_once('recaptchalib.php');
$publickey = "xxxxxxxxxxxxxxxxxxxxxxxxx"; // you got this from the signup page
echo recaptcha_get_html($publickey);
?>
</p>
<p><input class="submit" type="submit" value="Submit" id="submit" name="submit"/></p></form>
<p class="right"><img alt="arrow up icon image" height="14" src="images/arrow_up.jpg" width="11" /> <a href="#top">Top</a></p>
</div><!--textbox_inner-->
</div><!--textbox_outer-->
<div class="clear"></div><!--cleardiv-->
<div id="footer">
</div><!--footer-->
</div><!--container-->
</body>
</html>

Inigoesdr
12-17-2010, 02:22 PM
What are the forums for if not to help people?
These forums definitely are for helping people, but it's disrespectful to ask people to do something for you when you could easily figure it out yourself. And you're never going to advance your knowledge if you always have to ask for help every step of the way. Take some initiative and do some searching. You'll find you can figure things out a lot easier yourself the vast majority of the time.

quartzy
12-17-2010, 02:25 PM
If I had someone to help me then I would have no need of using this forum for hlep. I believe I may have misunderstood you on one point and that is why the form is wrong. My paths are OK, they are all in the php-files folder except the thanks page.

You wrote this code and wrote to add my private key which I have done.


<?php
session_start();
require_once('recaptchalib.php');
$privatekey = "";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);

I called the above code recaptchalib.php

But Where does this code go? at the top of my volunteer form? or in the process.php page or what?


<?php
session_start();

// I think your contact form and this script are in two different directories ...
// so, I am blindly adjusting the path to recaptchalib.php ...

require_once('../recaptchalib.php');
$privatekey = "your_private_key";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);

// Get variables from your form ...
$username = $_POST['name'];
$useraddress = $_POST['address'];
$useremail = $_POST['email'];
$usertelephone = $_POST['telephone'];
$userskills = $_POST['skills'];
$userhours = $_POST['hours'];
$useroccassional = $_POST['occassional'];
$usersigned = $_POST['signed'];
$userdate = $_POST['date'];

// Who the form gets sent to ...
$recipient = "";
$subject = "Volunteering Form";

// Where to go after the user submits the form ...
$redirect = "../thanks.html";

// This tests whether or not the code was correct.
// For now, we are just going to return to the form ... wherever that is ...
// If this works, we will revisit this and use PHP SESSION to remember
// what the user entered on the form. For now, we just do this.

if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly ...
header("Location: http://www.leeoasis.org.uk.php_files/volunteer_form.php");
} else {
// Successful captcha, so continue on with the email ...
}

$message = "
================================
Name: $username
Address: $useraddress
Email: $useremail
Telephone: $usertelephone
Skills: $userskills
Hours: $userhours
Occassional: $useroccassional
Signed: $usersigned
Todaydate: $userdate

-----------------------------------------
$fmessage
================================
";

$extraheaders = "From: $useremail\n\nReply-To: $useremail\n\n";

if (! mail($recipient, $subject, $message, $extraheaders))
echo "Mail did not send for some reason.";

header("Location: ".$redirect);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Volunteer Form Process</title>
</head>

<body>

</body>

</html>

This is the only thing where I have got confused as I do not know where to put it. No you are not holding me back, you are offering your help which is great.

quartzy
12-17-2010, 02:43 PM
Moderator
I know nothing about php and that is why I have come to this forum. Learners are always anxious, and unsure and you should know this. Plus everyone has a different learning rate.

mlseim
12-17-2010, 03:18 PM
You should put all of your scripts in the same directory ...
Because the paths are causing confusion.

You have a script called "recaptchalib.php"
You don't have to do anything with that script, except put it in the same directory as the others.

You have the script called "volunteer_form.php".
Put that in the same directory as all the others.
Put your PUBLIC KEY in that script ... where it indicates.

You have the script called "process.php".
Put that in the same directory as all the others.
Put your PRIVATE KEY in that script ... where it indicates.

You have the script called "thanks.html".
Put that in the same directory as all the others.

Put all of the the files I mentioned above IN THE SAME DIRECTORY.


And here are the scripts again ...

"volunteer_form.php"


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Language" content="en-gb" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<title>Volunteering Form</title>
<link href="styles/layout.css" rel="stylesheet" type="text/css" />
<link href="styles/mainstyle.css" rel="stylesheet" type="text/css" />
<link href="styles/form.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container">
<div id="header">
<div id="left_header"><h1 id="logo"><a href="" title="Lee Oasis Furniture Project"><em title="Lee Oasis Home Page"></em>Lee Oasis Furniture Project</a></h1>
</div><!--left_header-->
<div id="right_header">
<p class="logtitle">Recycle and donate<br />unwanted furniture<br/>Tel: 020 8857
0043<br /><span class="caps">Lewisham Area</span></p></div><!--right_header-->
</div><!--header-->
<div class="clear"></div><!--clear-->
<div id="nav"><a id="top"></a>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About Us</a></li>
<li><a href="dropin.html">Drop-in</a></li>
<li><a href="furniture.html">Furniture Project</a></li>
<li class="current"><a href="volunteer.html">Volunteer</a></li>
<li><a href="news.html">News/Events</a></li>
<li id="last"><a href="appeals.html">Appeals</a></li>
</ul>
</div><!--nav-->
<div class="textbox_outer">
<div class="textbox_inner">
<h2>Volunteering Form</h2>
<form class="volunteering" action="process.php" method="post" enctype="multipart/form-data" name="form_to_email">
<fieldset><legend>Details</legend><p><label id="name"><span>Name:</span></label><input type="text" size="30" name="name" /></p>
<p><label id="address"><span>Address:</span></label><textarea name="address" rows="5" cols="30"></textarea></p>
<p><label id="email"><span>Email:</span></label><input type="text" size="30" name="email" /></p>
<p><label id="telephone"><span>Telephone:</span></label><input type="text" size="30" name="telephone" /></p></fieldset>
<fieldset><legend>Skills and Time</legend><p><label id="skills"><span>What would you like to do/skills offered:</span></label><textarea name="skills" rows="5" cols="30"></textarea></p>
<p>How much time do you have available?</p>
<p><label id="hours"><span>Hours per week/month?</span></label><input type="text" size="30" name="hours" /></p>
<p><label id="occassional"><span>On Occassional Basis?</span></label><input type="text" size="30" name="occassional" /></p></fieldset><br />
<p class="formtext">I understand the general policy of Lee Oasis and agree with its aims and ethos. I have also read the relevant
<a href="pdf-files/Drivers%20health%20and%20safety%20and%20child%20protection.pdf">Health and Safety</a> and/or
<a href="pdf-files/Drop%20In%20Child%20Protection%20and%20Health%20and%20Safety.pdf">Child Protection Policy</a> as it applies to me; and agree to abide by it.</p><br />
<fieldset><legend>Sign and Date</legend><p><label id="signature"><span>Signed (Add name and submit form):</span></label><input type="text" size="30" name="signed" /></p>
<p><label id="date"><span>Date:</span></label><input type="text" size="30" name="date" /></p></fieldset>
<p>
<?php
require_once('recaptchalib.php');
$publickey = "xxxxxxxxxxxxxxxxxxxxxxxx"; // you got this from the signup page
echo recaptcha_get_html($publickey);
?>
</p>
<p><input class="submit" type="submit" value="Submit" id="submit" name="submit"/></p></form>
<p class="right"><img alt="arrow up icon image" height="14" src="images/arrow_up.jpg" width="11" /> <a href="#top">Top</a></p>
</div><!--textbox_inner-->
</div><!--textbox_outer-->
<div class="clear"></div><!--cleardiv-->
<div id="footer">
</div><!--footer-->
</div><!--container-->
</body>
</html>



This is your "process.php" script ....


<?php
session_start();

require_once('recaptchalib.php');
$privatekey = "your_private_key";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);

// Get variables from your form ...
$username = $_POST['name'];
$useraddress = $_POST['address'];
$useremail = $_POST['email'];
$usertelephone = $_POST['telephone'];
$userskills = $_POST['skills'];
$userhours = $_POST['hours'];
$useroccassional = $_POST['occassional'];
$usersigned = $_POST['signed'];
$userdate = $_POST['date'];

// Who the form gets sent to ...
$recipient = "";
$subject = "Volunteering Form";

// Where to go after the user submits the form ...
$redirect = "thanks.html";

// This tests whether or not the code was correct.
// For now, we are just going to return to the form ... wherever that is ...
// If this works, we will revisit this and use PHP SESSION to remember
// what the user entered on the form. For now, we just do this.

if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly ...
header("Location: http://www.leeoasis.org.uk/volunteer_form.php");
} else {
// Successful captcha, so continue on with the email ...
}

$message = "
================================
Name: $username
Address: $useraddress
Email: $useremail
Telephone: $usertelephone
Skills: $userskills
Hours: $userhours
Occassional: $useroccassional
Signed: $usersigned
Todaydate: $userdate

-----------------------------------------
$fmessage
================================
";

$extraheaders = "From: $useremail\n\nReply-To: $useremail\n\n";

if (! mail($recipient, $subject, $message, $extraheaders))
echo "Mail did not send for some reason.";

header("Location: ".$redirect);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Volunteer Form Process</title>
</head>

<body>

</body>

</html>

quartzy
12-18-2010, 12:07 PM
I never knew that I had to download recapchalib and add my own key to it, so it is now working. I am not happy at the way certain people on this thread have been with me. When I am a learner, on the whole this forum is usually very helpful.

mlseim
12-18-2010, 12:33 PM
You're not done yet ...

So, you've tested it all. The recaptcha works if you enter correctly,
you get the email, if not, it goes back to your form. Does it all work correctly?

When it goes back to the form, all of the form boxes are empty? is that correct?
If so, we need to remember what the user put into those boxes.

Let me know if you want it to remember what was put into the form.
Repost both scripts again, so I can insert the PHP SESSION stuff into it correctly.




.

quartzy
12-18-2010, 01:21 PM
I do not think that my posts are working.

quartzy
12-18-2010, 01:29 PM
I now have 4 scripts.

recapturelib (mostly downloaded) some of it is probably redundant. So posted only what I added.


require_once('recaptchalib.php');

$publickey = "removed"; // you got this from the signup page
echo recaptcha_get_html($publickey);

function _recaptcha_qsencode ($data) {
$req = "";
foreach ( $data as $key => $value )
$req .= $key . '=' . urlencode( stripslashes($value) ) . '&';

// Cut the last '&'
$req=substr($req,0,strlen($req)-1);
return $req;
}



Process.php

<?php
session_start();

require_once('recaptchalib.php');
$privatekey = "removed";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);

// Get variables from your form ...
$username = $_POST['name'];
$useraddress = $_POST['address'];
$useremail = $_POST['email'];
$usertelephone = $_POST['telephone'];
$userskills = $_POST['skills'];
$userhours = $_POST['hours'];
$useroccassional = $_POST['occassional'];
$usersigned = $_POST['signed'];
$userdate = $_POST['date'];

// Who the form gets sent to ...
$recipient = "";
$subject = "Volunteering Form";

// Where to go after the user submits the form ...
$redirect = "../thanks.html";

if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly ...
header("Location: http://www.leeoasis.org.uk/php_files/volunteer_form.php");
} else {
// Successful captcha, so continue on with the email ...
}

$message = "
================================
Name: $username
Address: $useraddress
Email: $useremail
Telephone: $usertelephone
Skills: $userskills
Hours: $userhours
Occassional: $useroccassional
Signed: $usersigned
Todaydate: $userdate

-----------------------------------------
$fmessage
================================
";

$extraheaders = "From: $useremail\n\nReply-To: $useremail\n\n";

if (! mail($recipient, $subject, $message, $extraheaders))
echo "Mail did not send for some reason.";

header("Location: ".$redirect);

?>


This is the form code:


<body>

<form class="volunteering" action="process.php" method="post" enctype="multipart/form-data" name="form_to_email"><fieldset><legend>Details</legend><p><label id="name"><span>Name:</span></label><input type="text" size="30" name="name" /></p><p><label id="address"><span>Address:</span></label><textarea name="address" rows="5" cols="30"></textarea></p><p><label id="email"><span>Email:</span></label><input type="text" size="30" name="email" /></p><p><label id="telephone"><span>Telephone:</span></label><input type="text" size="30" name="telephone" /></p></fieldset><fieldset><legend>Skills and Time</legend><p><label id="skills"><span>What would you like to do/skills offered:</span></label><textarea name="skills" rows="5" cols="30"></textarea></p><p>How much time do you have available?</p>
<p><label id="hours"><span>Hours per week/month?</span></label><input type="text" size="30" name="hours" /></p><p><label id="occassional"><span>On Occassional Basis?</span></label><input type="text" size="30" name="occassional" /></p></fieldset><br /><p class="formtext">I understand the general policy of Lee Oasis and agree with its aims and ethos. I have also read the relevant
<a href="../pdf-files/Drivers%20health%20and%20safety%20and%20child%20protection.pdf">Health and Safety</a> and/or <a href="../pdf-files/Drop%20In%20Child%20Protection%20and%20Health%20and%20Safety.pdf">Child Protection Policy</a> as it applies to me; and agree to abide by it.</p><br /><fieldset><legend>Sign and Date</legend><p><label id="signature"><span>Signed (Add name and submit form):</span></label><input type="text" size="30" name="signed" /></p><p><label id="date"><span>Date:</span></label><input type="text" size="30" name="date" /></p></fieldset>

<div class="captcha"><script type="text/javascript">
var RecaptchaOptions = {
theme : 'clean',
tabindex : 0
};
</script><noscript><p>Please enable javascript in your browser to post this form</p></noscript>
<br />
<?php
require_once('recaptchalib.php');
$publickey = "removed"; // you got this from the signup page
echo recaptcha_get_html($publickey);
?></div>
<p><input class="submit" type="submit" value="Submit" id="submit" name="submit"/></p></form>


Bits of that form are removed for space.

And after reading the resources at the captcha site I now have verify.php


<?php
require_once('recaptchalib.php');
$privatekey = "Removed";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);

if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
"(reCAPTCHA said: " . $resp->error . ")");
} else {
mail ($to, $subject, $message, $headers);
header("Location: process.php");
}
?>

On this form I have changed what comes after the last else{ to get it to go to process.php but it does not work. If it is not too difficult then keeping the form info might be good, but I am not really bothered.

quartzy
12-18-2010, 05:34 PM
the verify was redundant. The form now works and sends me the form details via email.

I really would like there not to be a glitch when the form is being sent to the process.php page. What happens now is that the form momentarily goes back to the form on submit, instead of just going to the thnaks page Is there a way to stop it from doing this?

mlseim
12-18-2010, 08:02 PM
And what is the reason for 4 scripts now?

I don't understand the verify script.

Once you added that script, you've now lost your form variables.

What didn't work on the previous 3 scripts you used to have?

quartzy
12-18-2010, 11:57 PM
See my previous post, I did say that the verify script is now redundant (hence not using it). I have a problem with the form not submitting correctly, ie it goes back to the form briefly.

mlseim
12-19-2010, 01:07 AM
Something still must not be right in the scripts.

Repost your two scripts again ...

volunteer_form.php
process.php

quartzy
12-19-2010, 02:26 AM
Volunteer_form


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Language" content="en-gb" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<title>Volunteering Form</title>
<link href="../styles/layout.css" rel="stylesheet" type="text/css" />
<link href="../styles/mainstyle.css" rel="stylesheet" type="text/css" />
<link href="../styles/form.css" rel="stylesheet" type="text/css" />
</head><body><div id="container"><div id="header"><div id="left_header"><h1 id="logo"><a href="" title="Lee Oasis Furniture Project"><em title="Lee Oasis Home Page"></em>Lee Oasis Furniture Project</a></h1></div><!--left_header--><div id="right_header"><p class="logtitle">Recycle and donate<br />unwanted furniture<br/>Tel: 020 8857 0043<br /><span class="caps">Lewisham Area</span></p></div><!--right_header--></div><!--header--><div class="clear"></div><!--clear--><div id="nav"><a id="top"></a><ul>
<li><a href="../index.html">Home</a></li>
<li><a href="../about.html">About Us</a></li>
<li><a href="../dropin.html">Drop-in</a></li>
<li><a href="../furniture.html">Furniture Project</a></li>
<li class="current"><a href="../volunteer.html">Volunteer</a></li>
<li><a href="../news.html">News/Events</a></li>
<li id="last"><a href="../appeals.html">Appeals</a></li>
</ul></div><!--nav--><div class="textbox_outer"><div class="textbox_inner"><h2>Volunteering Form</h2>

<form class="volunteering" id="form" action="process.php" method="post" enctype="multipart/form-data" name="form_to_email">

<fieldset><legend>Details</legend><p><label id="name"><span>Name:</span></label><input type="text" size="30" name="name" /></p><p><label id="address"><span>Address:</span></label><textarea name="address" rows="5" cols="30"></textarea></p><p><label id="email"><span>Email:</span></label><input type="text" size="30" name="email" /></p><p><label id="telephone"><span>Telephone:</span></label><input type="text" size="30" name="telephone" /></p></fieldset><fieldset><legend>Skills and Time</legend><p><label id="skills"><span>What would you like to do/skills offered:</span></label><textarea name="skills" rows="5" cols="30"></textarea></p><p>How much time do you have available?</p>
<p><label id="hours"><span>Hours per week/month?</span></label><input type="text" size="30" name="hours" /></p><p><label id="occassional"><span>On Occassional Basis?</span></label><input type="text" size="30" name="occassional" /></p></fieldset><br /><p class="formtext">I understand the general policy of Lee Oasis and agree with its aims and ethos. I have also read the relevant
<a href="../pdf-files/Drivers%20health%20and%20safety%20and%20child%20protection.pdf">Health and Safety</a> and/or <a href="../pdf-files/Drop%20In%20Child%20Protection%20and%20Health%20and%20Safety.pdf">Child Protection Policy</a> as it applies to me; and agree to abide by it.</p><br /><fieldset><legend>Sign and Date</legend><p><label id="signature"><span>Signed (Add name and submit form):</span></label><input type="text" size="30" name="signed" /></p><p><label id="date"><span>Date:</span></label><input type="text" size="30" name="date" /></p></fieldset>

<div class="captcha"><script type="text/javascript">
var RecaptchaOptions = {
theme : 'clean',
tabindex : 0
};
</script><noscript><p>Please enable javascript in your browser to post this form</p></noscript>
<br />
<?php
require_once('recaptchalib.php');
$publickey = "removed"
echo recaptcha_get_html($publickey);
?></div>

<p><input class="submit" type="submit" value="Submit" id="submit" name="submit" onclick="return validate.js();"/></p></form>

<p class="right"><img alt="arrow up icon image" height="14" src="../images/arrow_up.jpg" width="11" /> <a href="#top">Top</a></p></div><!--textbox_inner--></div><!--textbox_outer--><div class="clear"></div><!--cleardiv--><div id="footer"></div><!--footer--></div><!--container--></body></html>

Process.php


<?php
session_start();

require_once('recaptchalib.php');
$privatekey = "Removed";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);

// Get variables from your form ...
$username = $_POST['name'];
$useraddress = $_POST['address'];
$useremail = $_POST['email'];
$usertelephone = $_POST['telephone'];
$userskills = $_POST['skills'];
$userhours = $_POST['hours'];
$useroccassional = $_POST['occassional'];
$usersigned = $_POST['signed'];
$userdate = $_POST['date'];

// Who the form gets sent to ...
$recipient = "Removed";
$subject = "Website Volunteering Form";

// Where to go after the user submits the form ...
$redirect = "../thanks.html";

if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly ...
header("Location: http://www.leeoasis.org.uk/php_files/volunteer_form.php");
} else {
// Successful captcha, so continue on with the email ...
}

$message = "
================================
Name: $username
Address: $useraddress
Email: $useremail
Telephone: $usertelephone
Skills: $userskills
Hours: $userhours
Occassional: $useroccassional
Signed: $usersigned
Todaydate: $userdate

-----------------------------------------
$fmessage
================================
";

$extraheaders = "From: $useremail\n\nReply-To: $useremail\n\n";

if (! mail($recipient, $subject, $message, $extraheaders))
echo "Mail did not send for some reason.";

header("Location: ".$redirect);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Volunteer Form Process</title>
</head>

<body>

</body>

</html>

By the way I got your test message.

mlseim
12-19-2010, 04:21 AM
Your process.php has some HTML on the bottom of it.
That needs to be removed.

This will be the new process.php script:


<?php
session_start();

require_once('recaptchalib.php');
$privatekey = "Removed";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);

// Get variables from your form ...
$username = $_POST['name'];
$useraddress = $_POST['address'];
$useremail = $_POST['email'];
$usertelephone = $_POST['telephone'];
$userskills = $_POST['skills'];
$userhours = $_POST['hours'];
$useroccassional = $_POST['occassional'];
$usersigned = $_POST['signed'];
$userdate = $_POST['date'];

// Save the form variables in SESSION
// We will be using this later.
$_SESSION['username'] = $_POST['name'];
$_SESSION['useraddress'] = $_POST['address'];
$_SESSION['useremail'] = $_POST['email'];
$_SESSION['usertelephone'] = $_POST['telephone'];
$_SESSION['userskills'] = $_POST['skills'];
$_SESSION['userhours'] = $_POST['hours'];
$_SESSION['useroccassional'] = $_POST['occassional'];
$_SESSION['usersigned'] = $_POST['signed'];
$_SESSION['userdate'] = $_POST['date'];

// Who the form gets sent to ...
$recipient = "Removed";
$subject = "Website Volunteering Form";

// Where to go after the user submits the form ...
$redirect = "../thanks.html";

if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly ...
$_SESSION['mess'] = "Invalid CAPTCHA";
header("Location: http://www.leeoasis.org.uk/php_files/volunteer_form.php");
} else {
// Successful captcha, so continue on with the email ...
}

$message = "
================================
Name: $username
Address: $useraddress
Email: $useremail
Telephone: $usertelephone
Skills: $userskills
Hours: $userhours
Occassional: $useroccassional
Signed: $usersigned
Todaydate: $userdate

-----------------------------------------
$fmessage
================================
";

$extraheaders = "From: $useremail\n\nReply-To: $useremail\n\n";

if (! mail($recipient, $subject, $message, $extraheaders))
echo "Mail did not send for some reason.";

header("Location: ".$redirect);

?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum