Hi everyone. I have a bit of an issue. I’m the admin / creator of blackoutpoetry.com and I’m trying to enable users to upload images. I’ve looked all over the web and found a few useful scripts for uploading, but I’m having a problem maintaining the functionality of the rest of my form. Here is the code I’m starting with.
Form: (found at blackoutpoetry.com/submit.php)
<form method="post" action="sendmail.php" name="msgform">
<p>
<label>Name:
<input type="text" name="name" id="name" />
</label>
<label>Email:
<input type="text" name="email" id="email" />
</label>
</p>
<p>
<label>Where ya from?:
<input type="text" name="location" id="location" />
</label>
</p>
<p>
<label>
How did you hear about BlackoutPoetry.com?:
<input type="text" name="hear" id="hear" /></label>
</p>
<p>
<label>Blackout URL*:
<input name="image" type="text" id="image" value="http://" />
</label>
<br /><font size="-2">*We are currently working on support of direct upload images. In the meantime we recommend using a third-party image hosting site, like <a href="http://www.flickr.com" target="_blank">flickr.com</a> or <a href="http://www.photobucket.com" target="_blank">photobucket.com</a></font>
</p>
<p>
<label>Blackout Description (240 Character Limit):
<br />
<textarea name="description" cols="60" rows="4" id="description"></textarea>
</label>
</p>
<p>Prove you're not a robot: <font size="-4"><a href="javascript:MDM_openWindow('why.html','Interface1','width=270,height=330')">(Why do I have to do this??)</a></font></p>
<div align="center">
<script type="text/javascript" src="http://api.recaptcha.net/challenge?k=6Lf2gwgAAAAAABngxMt5mHRC5USNnT8bjNHjDwQP"></script>
<noscript>
<iframe src="http://api.recaptcha.net/noscript?k=6Lf2gwgAAAAAABngxMt5mHRC5USNnT8bjNHjDwQP" height="300" width="500" frameborder="0"></iframe><br/>
<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
<input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
</noscript>
<br />
<input type="submit" value="Submit" /> <input type="reset" value="Clear Form" /></p>
</div>
</form>
Server Side PHP Script: (sendmail.php)
<?php
require_once('recaptchalib.php');
$privatekey = "6Lf2gwgAAAAAAEOhPT7XGI4fegpxVUcXEnK8Tm9m";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if(!$resp->is_valid) {
header("location:captcha_error.php");
die();}
else if($resp->is_valid)
{
$to = "mike@blackoutpoetry.com";
$subject = "Blackout Poetry Submission";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$location_field = $_POST['location'];
$image_field = $_POST['image'];
$hear_field = $_POST['hear'];
$description_field = $_POST['description'];
$body = "From: $name_field
E-Mail: $email_field
Location: $location_field
Heard: $hear_field
Image: $image_field
Description: $description_field";
mail($to, $subject, $body);
header( "Location: http://www.blackoutpoetry.com/thanks.html" );
}
?>