Jump to content

Photo Upload in Registration Script


ShoeLace1291

Recommended Posts

I can't seem to get my photo upload script to work.  I have it output a couple different messages if there was a problem uploading it or if a user chose a wrong file type, etc.  Both of my messages are displayed but I can't seem to figure out why my logic isn't working.  This is my form:

 

<td align='center'><table align='center' cellspacing='1' cellpadding='1' border='0'>
 		 <tr><form action='join.php' method='POST' endtype="multipart/form-data">
		 	 <td align='center' colspan='2'><b>New Player Registration</b></td>
		</tr><tr>
			<td align='right'>Online Alias: </td>
			<td align='left'><input type='text' name='alias' size='30'></td>
		</tr><tr>
			<td align='right'>Player Password: </td>
			<td align='left'><input type='password' name='password' size='30'></td>
		</tr><tr>
			<td align='right'>Confirm Password: <a href='faq.php'>?</a></td>
			<td align='left'><input type='password' name='confirm' size='30'></td>
		</tr><tr>
			<td align='right'>E-Mail Address: </td>
			<td align='left'><input type='text' name='email' size='30'></td>
		</tr><tr>
			<td align='right'>Timezone: </td>
			<td align='left'>TIMEZONESMENU</td>
		</tr><tr>
			<td align='right'>Photo: </td>
			<td align='left'><input type='file' name='file' size='30'></td>
		</tr><tr>
 			 <td align='center' colspan='2'><input type='submit' value='Submit' name='submit'></td>
	</tr></form>
</table></td>

 

This is my script:

  	   $alias = $_POST['alias'];
  	   $password = md5($_POST['password']);
  	   $confirm = md5($_POST['confirm']);
	   $email = $_POST['email'];
   $time = $_POST['timezone'];
   $photoname = $_FILES['file']['name'];
   $phototype = $_FILES['file']['type'];

  if( ($phototype != "image/jpeg") && ($phototype != "image/gif") && ($phototype != "image/png") )
{
   
   		echo "The photo you have chosen to upload is in an incorrect file format.  Allowed formats are jpeg, gif, and png.  You chose a $phototype.";
		$errors = $errors + 1;

}
   
   $errors = 0;
   
   if(!$alias){
   
   		echo "You did not enter an Online Alias.  Please go back and fix this error.";
		$errors = $errors + 1;

	}

	if(!$password){
				   
		echo "You did not enter a password.  Please go back and fix this error.";
		$errors = $errors + 1;

	}

	if(!$confirm){

		echo "You did not confirm your password.  Please go back and enter the password exactly as you entered it in the Player Password field.";
		$errors = $errors +1;

	}

	if(!$email){

		echo "You did not enter an e-mail address.  Please go back and fix this error.";
		$errors = $errors + 1;

	}

	if(!($password == $confirm)){

		echo "The passwords you entered did not match.  Please go back and fix this error.";
		$errors = $errors + 1;

	}
	$length = 32;
	$actcode = generate_actcode($length);


	   

	if($errors == 0){

	$subject = "Storm Gaming League Registration";
	$message = "Hello, $alias.  Thank you for joining Storm Gaming League.  Before you can use all features of the site, you must first activate your account.  You can do so by visiting the link below:<br><br><a href='localhost/ladders/join.php?do=activate&code=$actcode'>localhost/ladders/join.php?do=activate&code=$actcode</a><br><br>If the above link did not work properly, you can also activate your account by copying localhost/ladders/join.php?do=activate and pasting it into your url bar.  You must then enter your activation code in the form provided on the page.  Your account will then be active if you entered it correctly.<br><br>If you are still having trouble with the account activation process, please email our support team.<br><br>Best regards,<br>Storm Gaming.net";
	$sender = "From: unholyprayer@stormgaming.net";

			   $query = mysql_query("INSERT INTO players(playerAlias,playerPassword,playerEmail,playerTimezone,activationCode)
			   		  values('$alias', '$password', '$email', '$timezone', '$actcode')") or die("Error: ".mysql_error());
					  
					  copy( $_FILES['file']['name'], "/photos" ) or 
           die("There was an error uploading your photo.  Please try again later.");
					  
				echo "Thank you for joining us, $alias.  Before you can start logging in and using the ladders, you must first activate your account by following instructions that have been included in an email sent to the address you provided.";

			mail($email,"Storm Gaming League Registration",$message,$sender);


	}

 

This is the message I get:

The photo you have chosen to upload is in an incorrect file format. Allowed formats are jpeg, gif, and png. You chose a .There was an error uploading your photo. Please try again later.

 

I chose a .jpg file from my computer but it still doesn't seem to be working.  Thanks in advance for any help.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.