homepage Welcome to WebmasterWorld Guest from 54.226.93.128
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Visit PubCon.com
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
Barman007




msg:3983840
 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){
if(function_exists(strip_tags)){
$value = strip_tags($value);
}

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

if(function_exists(addslashes)){
$value = addslashes($value);
}else{
$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.";
exit();
}else{
echo "ok!";
}
}

}else{
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" />

</form>

 

parorrey




msg:3983923
 11:10 am on Sep 4, 2009 (gmt 0)

Hi,

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