[ Поиск ] - [ Пользователи ] - [ Календарь ]
Полная Версия: Пожалуйста, помогите прикрутить отправку аватара
PicLive
К форме регистрации прикручиваю отправку аватара.
Смог сделать саму функцию выбора аватара и отправку его в базу данных mysql, адрес сохраняется от имени изображения, вида hdhf.jpg

Т.е. в бд аватар сохраняется, но я не могу создать функцию отправки самой картинки на сервер с проверкой на содержимое файла.
Помогите отправить изображение в папку avatars

Мой код

<?php
session_start();

include("db-info.php");
$link = mysql_connect($server, $user, $pass);
if(!mysql_select_db($database)) die(mysql_error());

include("session.inc.php");
include("loadsettings.inc.php");
?>

<?php
include("header.php"); ?>


<!-- ################################################################################################# -->

<br>
<
LABEL id="message" style="COLOR: maroon">
<?php

if (isset($_POST["username"])) {
$username = htmlspecialchars(trim($_POST["username"]));
$password = htmlspecialchars(trim($_POST["password"]));
$password1 = htmlspecialchars(trim($_POST["password1"]));
$userpass = htmlspecialchars(trim($_POST["userpass"]));
$email = htmlspecialchars(trim($_POST["email"]));
$foto = htmlspecialchars(trim($_POST["foto"]));

echo "<br>";

if (isset($_POST["agree"])) {

if (($username != "") && ($password != "") && ($password1 != "") && ($email != ""))
{
if ((strlen($password) > 5) && (strlen($userpass) > 5)) {

if ($password == $password1)
{
$q = "SELECT username FROM `members` WHERE (username = '$username') or (email = '$email')";
if(!($result_set = mysql_query($q))) die(mysql_error());
$number = mysql_num_rows($result_set);

if ($number) {
echo "Sorry ! An account with the specified username and/or email already exists.<br><br>";
showForm();
}
else {
$q = "INSERT INTO `members` (username, password, foto, userpass, email) VALUES('$username', '$password', '$foto', '$userpass', '$email')";
$result_set = mysql_query($q);

$to = $email;
$subject = "Добро пожаловать на $webtitle !";
$body = "Привет $username, \n\nThank you for registering at $webtitle !\n\nThis email contains your registration information.\nYour username & password are shown below for your reference\n\nUser: $username\nPass: $password\nUser Pass: $userpass \n\nThanks!\n{$website}";
$headers = "From: $webtitle <{$website}>";

if(mail ($to, $subject, $body, $headers)) {
echo "Your account has been created successfully.
<br>A welcome email has been sent to the email address you specified.
<br><a href=
\"/login.php\">Click here</a> to login.";
}
else
echo "Your account has been created successfully.<br>Sorry ! The email could not be sent due to some reason.";

$invite = $_POST["invite"];
for ($i=0; $i < 5; $i++) {
if (trim($invite[$i]) != "") {
$to = $invite[$i];
$subject = "$webtitle Invitation";
$features = "Upload multiple pictures at one time\nCreate public and private galleries\nTheir dedicated servers host your images\nLink your photos in websites, email, blogs\nRegister an account to manage your files\nAdd tags to each of your photos\nUpload private images with password\nShare your images with friends and family";

$body = "Hello ! \n\nI have just joined $webtitle .\nIt provides free image hosting service with a whole bunch of features!\n\nFeatures:\n{$features}\n\nSo what are you waiting for?\nGoto $website and join instantly.\n\nThanks,\n$username";
$headers = "From: $username <$email>";

mail($to, $subject, $body, $headers);
}
}

}
}

else
{ echo "Sorry ! Your passwords do not match.<br><br>"; showForm();}
}

else
{ echo "Your password should be atleast 6 characters long.<br><br>"; showForm(); }
}

else
{ echo "Please fill in all the fields first !<br><br>"; showForm(); }
}

else
{ echo "Sorry! You must abide by our <a href='terms.php'>Terms and Conditions</a>
in order to proceed in the signup process.<br><br>"
; showForm(); }


}

else
{
if ($session == false)
showForm();
else
echo "Sorry ! You are already logged in.";
}


//************************************************************************************************** ********
?>
</LABEL>


<? function showForm() { ?>

<div>

<
table>
<
tr>
<
td width=600>

<
form method="POST" action="/register.php" name="myForm">

<
h1>Регистрация на сайте</h1>

<
LABEL id="text">Заполните необходимые поля помеченные звездочкой *</LABEL>
<
br><br><br>

<
table>
<
tr>
<
td><LABEL>Логин: *</td> <td> <input type="text" size=30 name="username"></td>
</
tr>
<
tr>
<
td><LABEL>Пароль: *</td> <td> <input type="password" size=30 name="password"></td>
</
tr>
<
tr>
<
td><LABEL>Повторите пароль: * </td> <td> <input type="password" size=30 name="password1"></td>
</
tr>
<
tr>
<
td><LABEL>Фото: * </td> <td> <input type="file" name="foto" /></td>
</
tr>
<
tr>
<
td> </td> <td><br> (Password for the users to view private images)</td>
</
tr>
<
tr>
<
td><LABEL id="title">Пользовательский пароль: * </td> <td> <input type="password" maxlength=30 size=30 name="userpass"> </td>
</
tr>
<
tr>
<
td><LABEL id="title">Email: *</td> <td> <input type="text" maxlength=40 size=30 name="email"> </td>
</
tr>

<
tr>
<
td> </td> <td> </td>
</
tr>

<
tr>
<
td></td>
<
td><br><input type="checkbox" name="agree">   С правилами <a href="/terms.php">согласен</a>.</td>
</
tr>

<
tr>
<
td></td>
<
td> <br><a href=#><img src="/theme/images/joinnow.png" border=0 onclick="myForm.submit();"></a></td>
</tr>
</
table>

</
form>

<
br><br>


</
td>


</
tr></table>

</
div>



<? } ?>

<!-- ################################################################################################# -->



</div><!-- .inner -->
</
section>
<?php include("footer.php"); ?>


Знаю, что сохранение в бд адреса в виде названия самой картинки не совсем корректно, буду благодарен если исправите на id пользователя или еще как.

Спасибо
Быстрый ответ:

 Графические смайлики |  Показывать подпись
Здесь расположена полная версия этой страницы.
Invision Power Board © 2001-2024 Invision Power Services, Inc.