Jump to content

[SOLVED] data not passing through $_POST....i think


Recommended Posts

hey i'm having a problem uploading image files in a simple registration form i'm making. it seems, as far as i can tell, that the form data for $_POST['image'] is not being passed through and is causing my script to fail at the mime type check. any ideas? here is the corresponding code:

$username = $_POST['username'];
$password = $_POST['password'];
$password = md5($password);
$email = $_POST['email'];
$zip = $_POST['zip'];
$image = $_FILES['image'];
$imagename = $_FILES['image']['name'];
$imagename = str_replace(' ', '_', $imagename);
echo $imagename;

$connect = mysql_connect(localhost, $user, $pass);
$db = mysql_select_db(user_data);

$sql = "SELECT * FROM user_data WHERE username='$username'";
$result = mysql_query($sql);
$num = mysql_num_rows($result);
//echo $num;

if($num == 0)
	$sql = "INSERT INTO `user_data`.`user_data` (`id`, `username`, `password`, `email`, `zipcode`, `picture_name`) VALUES (NULL, '$username', '$password', '$email','$zip', '$imagename');";
	echo "<center>Registration Successful</center>";
	echo "<center>Username Already Taken.</center>";

$imageinfo = getimagesize($image); 
if($imageinfo['mime'] != 'image/gif' && $imageinfo['mime'] != 'image/jpeg' && $imageinfo['mime'] != 'image/jpe' && $imageinfo['mime'] != 'image/jpg')
    	echo "That is an invalid file type, you must upload either a JPEG or GIF file.\n Please use your browser's 'Back' button and try again.\n"; 

$uploaddir = "user_images/"; 
$uploadfile = $uploaddir.basename($imagename); 
if (move_uploaded_file($image, $uploadfile)) { 
    	echo "File Upload Successful.\n";}

<link REL="SHORTCUT ICON" HREF="favicon.ico">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>


<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<form name="form1" method="post" action="register.php">
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<td colspan="3" align="center"><strong>Member Registration </strong></td>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input name="username" type="text" id="username"></td>
<td><input name="password" type="password" id="password"></td>
<td><input name="email" type="text" id="email"></td>
<td><input name="zip" type="text" id="zip"></td>
<td><input name="image" type="file" id="image"></td>
<td> </td>
<td> </td>
<td align="right"><input type="submit" name="Submit" value="Register"></td>

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.

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.