Едит на стойност

aquafresh

Registered
Това ми е файла едит.пхп ,но не може да едитва.. :?

Код:
<?php
include ("config.php");
$id=(int)$_GET['id'];
$db=mysql_query("SELECT * FROM $table_name WHERE id='$id'");
while ($r=mysql_fetch_array($db))
{
$password=$r['password'];
$email=$r['email'];
$name=$r['name'];
$opisanie=$r['opisanie'];
$avatar=$r['avatar'];
$sex=$r['sex'];
$country=$r['country'];
}
echo "
<form method='post' action=''>
Парола:<br />
<input name='password' type='password' class='txt' id='password' 'size='30' value='password' /><br />
Е-мейл:<br />
<input name='email' type='text' class='txt' id='email' 'size='30' value='$email' /><br />
Име:<br />
<input name='name' type='text' class='txt' id='name' 'size='30' value='$name' /><br />
Описание:<br/>
<textarea name='opisanie' cols='40' rows='5' value='$opisanie'></textarea><br />
Аватар:<br />
<input name='avatar' type='text' class='txt' id='avatar' 'size='30' value='$avatar' /><br />
Пол:<br/>
<select name='sex'>
<option value='man.png'>Мъж</option>
<option value='girl.png'>Жена</option>
</select>
<br />
Име:<br />
<input name='name' type='text' class='txt' id='name' 'size='30' value='$name' /><br />
Държава:<br />
<select name='country'>
<option>България</option>
<option>Англия</option>
<option>САЩ</option>
<option>Другаде</option>
</select><br />
<br />
<input name='submit' type='submit' id='button' value='Регистрирай ме !' />
</form>
";

if (isset($_POST['edit']))
{
$password=$_POST['password'];
$email=$_POST['email'];
$name=$_POST['name'];
$opisanie=$_POST['opisanie'];
$avatar=$_POST['avatar'];
$sex=$_POST['sex'];
$country=$_POST['country'];
if ($password != null || $email != null || $name != null || $opisanie != null || $avatar != null || $sex != null || $country != null)
{
mysql_query("UPDATE $table_name SET password='$password',email='$email',name='$name',opisanie='$opisanie',avatar='$avatar',sex='$sex',country='$country' WHERE id='$id'");
echo "Профила ви е променен";
}
else
{
echo "Не сте попълнили всички полета.";
}
}
?>
 
<?php
include ("config.php");
$table_name = 'table name';
$id=(int)$_GET['id'];
$db=mysql_query("SELECT * FROM $table_name WHERE id='$id'");
while ($r=mysql_fetch_array($db))
{
$password=$r['password'];
$email=$r['email'];
$name=$r['name'];
$opisanie=$r['opisanie'];
$avatar=$r['avatar'];
$sex=$r['sex'];
$country=$r['country'];
}
echo "
<form method='post' action=''>
Парола:<br />
<input name='password' type='password' class='txt' id='password' 'size='30' value='password' /><br />
Е-мейл:<br />
<input name='email' type='text' class='txt' id='email' 'size='30' value='$email' /><br />
Име:<br />
<input name='name' type='text' class='txt' id='name' 'size='30' value='$name' /><br />
Описание:<br/>
<textarea name='opisanie' cols='40' rows='5' value='$opisanie'></textarea><br />
Аватар:<br />
<input name='avatar' type='text' class='txt' id='avatar' 'size='30' value='$avatar' /><br />
Пол:<br/>
<select name='sex'>
<option value='man.png'>Мъж</option>
<option value='girl.png'>Жена</option>
</select>
<br />
Име:<br />
<input name='name' type='text' class='txt' id='name' 'size='30' value='$name' /><br />
Държава:<br />
<select name='country'>
<option>България</option>
<option>Англия</option>
<option>САЩ</option>
<option>Другаде</option>
</select><br />
<br />
<input name='submit' type='submit' id='button' value='Регистрирай ме !' />
</form>
";

if (isset($_POST['edit']))
{
$password=$_POST['password'];
$email=$_POST['email'];
$name=$_POST['name'];
$opisanie=$_POST['opisanie'];
$avatar=$_POST['avatar'];
$sex=$_POST['sex'];
$country=$_POST['country'];
if ($password != null || $email != null || $name != null || $opisanie != null || $avatar != null || $sex != null || $country != null)
{
mysql_query("UPDATE $table_name SET password='$password',email='$email',name='$name',opisanie='$opisanie',avatar='$avatar',sex='$sex',country='$country' WHERE id='$id'");
echo "Профила ви е променен";
}
else
{
echo "Не сте попълнили всички полета.";
}
}
?>


Промени текста в червено с името на таблицата в която ще порменяш
 
<?php
$dbhost="localhost";
$dbusername="root";
$dbpassword="33333333333";
$db_name="ssssssssssss";
$table_name = "users";
$connect = mysql_connect($dbhost, $dbusername, $dbpassword);
$db = mysql_select_db($db_name,$connect) or die ("Could not select database");
echo "<META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=windows-1251'> ";
?>
 
Код:
 <?php
include ("config.php");
$id=(int)$_GET['id'];
$db=mysql_query("SELECT * FROM $table_name WHERE id='$id'");
while ($r=mysql_fetch_array($db))
{
$password=$r['password'];
$email=$r['email'];
$name=$r['name'];
$opisanie=$r['opisanie'];
$avatar=$r['avatar'];
$sex=$r['sex'];
$country=$r['country'];
}
echo "
<form method='post' action=''>
Парола:<br />
<input name='password' type='password' class='txt' id='password' 'size='30' value='password' /><br />
Е-мейл:<br />
<input name='email' type='text' class='txt' id='email' 'size='30' value='$email' /><br />
Име:<br />
<input name='name' type='text' class='txt' id='name' 'size='30' value='$name' /><br />
Описание:<br/>
<textarea name='opisanie' cols='40' rows='5' value='$opisanie'></textarea><br />
Аватар:<br />
<input name='avatar' type='text' class='txt' id='avatar' 'size='30' value='$avatar' /><br />
Пол:<br/>
<select name='sex'>
<option value='man.png'>Мъж</option>
<option value='girl.png'>Жена</option>
</select>
<br />
Име:<br />
<input name='name' type='text' class='txt' id='name' 'size='30' value='$name' /><br />
Държава:<br />
<select name='country'>
<option>България</option>
<option>Англия</option>
<option>САЩ</option>
<option>Другаде</option>
</select><br />
<br />
<input name='submit' type='submit' id='button' value='Регистрирай ме !' />
</form>
";

if(isset($_POST['submit']))
{
$password=$_POST['password'];
$email=$_POST['email'];
$name=$_POST['name'];
$opisanie=$_POST['opisanie'];
$avatar=$_POST['avatar'];
$sex=$_POST['sex'];
$country=$_POST['country'];
if ($password != null || $email != null || $name != null || $opisanie != null || $avatar != null || $sex != null || $country != null)
{
mysql_query("UPDATE $table_name SET password='$password',email='$email',name='$name',opisanie='$opisanie',avatar='$avatar',sex='$sex',country='$country' WHERE id='$id'");
echo "Профила ви е променен";
}
else
{
echo "Не сте попълнили всички полета.";
}
}
?>
я пробвай така
 
НП :) Проблема беше във
if(isset($_POST['submit']))
беше
if(isset($_POST['edit'])) а трябва да е със submit
 

Back
Горе