Notice: Undefined index: name on line 13


#1

Hi all, i have a problem with this error

<table width="300" height="10" border="1"> 
<tr><td>Добави новина</td></tr></table> 

<?php 

$dbhost = "localhost"; 
$dbuser = "root"; 
$dbpass = ""; 
$dbname = "news"; 
$conn = mysql_connect($dbhost, $dbuser, $dbpass)or die(mysql_error()); 
mysql_select_db($dbname, $conn)or die(mysql_error()); 

if ($_POST['name'] && $_POST['news']) 
mysql_query("REPLACE INTO news VALUES(".intval ($_GET['tid']).",'".$_POST['name']."','".$_POST['news']."')"); 

$select = mysql_query("SELECT * FROM news WHERE id=".intval($_GET['tid']))or die(mysql_error()); 
if (mysql_num_rows($select)) $red = mysql_fetch_array($select); 

mysql_close(); 
?> 

<form action="<?php echo($_SERVER['PHP_SELF']."?tid=".$_GET['tid']);?>" method="post"> 
Име на новина: <input type="text" name="name" value="<?php echo($red['name']);?>" /> 
<br /> 
Цялата новина: <input type="text" name="news" value="<?php echo($red['news']);?>" /> 
<br /> 
<input type="submit" name="submit" value="Редактирай" /> 
</form>

#2

This code is everything you could possibly do wrong. Toss it and learn how to use PDO with prepared statements for starters. There is no point getting into everything wrong with this. It is ALL very bad.