homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

PHP Form Help please
Php form help, emailing and uploading images

5+ Year Member

Msg#: 3983838 posted 5:00 am on Sep 4, 2009 (gmt 0)

Hi guys, well i'm a third year IT student who is building a website for my third year project and im running into some problems with a simple form im trying to make. I have some basic code i've put together but it is no where near finished. I was wondering if anyone would be able to help me out :)

I want people to be able to enter their details and attach a photo of themselves and then the script emails this to my email address and if possible auto resizes their image if it too large. Im saving the images to a folder on the site and plan on putting a link in the email to the image. If its possible to send the email with the image just in their it would be better, but I havnt been able to figure out how that would work.

Any help would be much appreciated. Here is my code so far, I know it has alot of more work to be done, but im kind of stuck now.

function cleanInput($value){
$value = strip_tags($value);

$value = mysql_real_escape_string($value);
}else if(function_exists(mysql_escape_string)){
$value = mysql_escape_string($value);

$value = addslashes($value);
$value = str_replace("'", "", $value);
$value = str_replace('"', '"', $value);

return $value;

if( empty( $_POST['name'] ) ¦¦ empty( $_POST['dob'] ) ¦¦ empty( $_POST['phone'] ) ¦¦ empty( $_POST['photo'] ) ¦¦ empty( $_POST['chk1'] ) ¦¦ empty( $_POST['chk2'] ) ){
$name = cleanInput( $_POST['name'] );
$dob = cleanInput( $_POST['dob'] );
$phone = cleanInput( $_POST['phone'] );
$imgfile = $_FILES['image']['name'];
$chk1 = cleanInput( $_POST['chk1'] );
$chk2 = cleanInput( $_POST['chk2'] );

if (is_uploaded_file($imgfile))
$newfile = "http://www.thebahamahut.co.nz/job_imgs/" . $name . rand(0,100) . $imgfile;

if (!copy($imgfile, $newfile))
echo "Error Uploading File.";
echo "ok!";

echo "FAIL!";


<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">

<strong>Name:</strong> &nbsp;&nbsp; <input name="name" id="joinUs_name" type="text" value="" /><br />
<strong>Date of Birth:</strong> &nbsp;&nbsp; <input name="dob" id="joinUs_dob" type="text" value="" /><br />
<strong>Contact phone number:</strong> &nbsp;&nbsp; <input name="phone" id="joinUs_phone" type="text" value="" /><br /><br />

<strong>Attach your photo:</strong> &nbsp;&nbsp; <input type="file" name="photo" id="joinUs_file" /><br /><br />

Your Application will be more sucessful with a photo. Tick if understood
<input type="checkbox" name="chk1" id="chk1" value="checkbox">
<br /><br />
This doesnt mean you are guaranteed a job. Tick if Agreed
<input type="checkbox" name="chk2" id="chk2" value="checkbox">
<br /><br />

<input type="submit" name="joinUsSubmit" value="SUBMIT" />




5+ Year Member

Msg#: 3983838 posted 11:10 am on Sep 4, 2009 (gmt 0)


For emailing image as attachment, use phpMailer class. [sourceforge.net...]

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved