uploading a profile picture and moving it

index.php
[php]

<?php include "process.php"; ?> <?php ini_set('error_reporting', E_ALL); ini_set('display_errors', '1'); ?> Form Sample <?php if (isset($msg)) { echo '

', $msg , '

'; } ?>
  1. Name * <?php if (isset($err_myname)) { echo $err_myname; } ?> <?php if (isset($err_patternmatch)) { echo $err_patternmatch; } ?>
  2. Profile Picture: (Image Files, <100000k)
  3. Password <?php if (isset($err_passlength)) { echo $err_passlength; } ?>
  4. Password (confirm) <?php if (isset($err_mypassconf)) { echo $err_mypassconf; } ?>
  5. Favorite Music
    1. /> Rock
    2. /> Classical
    3. /> Reggaeton
  6. How did you hear about us? Choose... >A friend >Facebook >Twitter
  7. Request Type
    1. /> Question
    2. /> Comment
    3. /> Suggestion
  8. Comment: (html is not allowed) <?php if (isset($mycomments)) { echo $mycomments; } ?>
send

[/php]

process.php

seems to be working fine until i add about 13 lines of code on this page below

<?php ini_set('error_reporting', E_ALL); ini_set('display_errors', '1'); if (($_SERVER['REQUEST_METHOD'] == 'POST') && (!empty($_POST['action']))): if (isset($_POST['myname'])) { $myname = $_POST['myname']; } if (isset($_POST['mypassword'])) { $mypassword = $_POST['mypassword']; } if (isset($_POST['mypasswordconf'])) { $mypasswordconf = $_POST['mypasswordconf']; } if (isset($_POST['mycomments'])) { $mycomments = filter_var($_POST['mycomments'], FILTER_SANITIZE_STRING ); } if (isset($_POST['reference'])) { $reference = $_POST['reference']; } if (isset($_POST['favoritemusic'])) { $favoritemusic = $_POST['favoritemusic']; } if (isset($_POST['requesttype'])) { $requesttype = $_POST['requesttype']; } $formerrors = false; if ($myname === '') : $err_myname = '
Sorry, your name is a required field
'; $formerrors = true; endif; // input field empty if (strlen($mypassword) <= 6): $err_passlength = '
Sorry, the password must be at least six characters
'; $formerrors = true; endif; //password not long enough if ($mypassword !== $mypasswordconf) : $err_mypassconf = '
Sorry, passwords must match
'; $formerrors = true; endif; //passwords don't match if ( !(preg_match('/[A-Za-z]+, [A-Za-z]+/', $myname)) ) : $err_patternmatch = '
Sorry, the name must be in the format: Last, First
'; $formerrors = true; endif; // pattern doesn't match //start of process code lesson 6-3 if (!($formerrors)): $tmp_name = $_FILES["myprofilepix"]["tmp_name"]; $uploadfilename = $_FILES["myprofilepix"]["name"]; $saveddate = date("mdy-Hms"); $newfilename = "uploads/".$saveddate."_".$uploadfilename; $uploadurl = 'http://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['REQUEST_URI']).'/'.$newfilename; if (move_uploaded_file($tmp_name, $newfilename)): $msg = "File Uploaded"; else: $msg = "Sorry, couldn't upload your profile picture".$_FILES['File']['error']; $formerrors = true; endif;// move uploaded file endif;// test for form errors $formdata = array ( 'myname' => $myname, 'mypassword' => $mypassword, 'mypasswordconf' => $mypasswordconf, 'mycomments' => $mycomments, 'reference' => $reference, 'favoritemusic' => $favoritemusic, 'requesttype' => $requesttype ); if (!($formerrors)) : $to = "[email protected]"; $subject = "From $myname -- Signup Page"; $message = json_encode($formdata); $replyto = "From: [email protected] \r\n". "Reply-To: [email protected] \r\n"; if (mail($to, $subject, $message)): $msg = "Thanks for filling out our form"; else: $msg = "Problem sending the message"; endif; // mail form data endif; // check for form errors endif; //form submitted ?>

I understand undefined index is something to do with error reporting but i have placed the code at top of my page that i thought would work

but instead i get this error message

Notice: Undefined index: myprofilepix in C:\xampp\htdocs\webs\06-03\workingfolder\forms\process.php on line 47

Notice: Undefined index: myprofilepix in C:\xampp\htdocs\webs\06-03\workingfolder\forms\process.php on line 48

Notice: Undefined index: File in C:\xampp\htdocs\webs\06-03\workingfolder\forms\process.php on line 57

have been through it about 6 times now thinking that i have mis-typed something

but i cannot see it am i turning into a blonde woman!

Please explain fully as technical jargon is difficult :smiley: :smiley: :smiley:

Is this happening after you click the submit button or before?

Sponsor our Newsletter | Privacy Policy | Terms of Service