didy Posted February 18, 2008 Report Posted February 18, 2008 (edited) <?php require ($_SERVER["DOCUMENT_ROOT"]."/folder/config.php"); $connection = @mysql_connect($db_host, $db_user, $db_password) or die ("error connecting"); mysql_select_db($db_name, $connection); $name = $_POST["txt_name"]; $len = strlen ($name); //Only write to database if there's a name if ($len > 0) { $email = $_POST["txt_email"]; $comment = $_POST["txt_comment"]; $date = time(); $query = "INSERT INTO guestbook (autoID, name, email, comment, date_auto) VALUES (NULL, '$name', '$email', '$comment', '$date')"; mysql_query($query, $connection) or die (mysql_error()); } ?> Problema: Notice: Undefined index: txt_name in E:\webroot\guestbook.php on line 5 ($name = $_POST["txt_name"];) kur kluda? Edited February 18, 2008 by didy
Vebers Posted February 18, 2008 Report Posted February 18, 2008 Kad submito formu drosi vien nav iestatiits txt_name.
andrisp Posted February 18, 2008 Report Posted February 18, 2008 Nuja nav nopostēta forma, tad loģiski, ka notice. Vajag ar isset vai empty vispirms pārbaudīt vai mainīgais eksistē un tad tikai kaut ko darīt ar to.
didy Posted February 19, 2008 Author Report Posted February 19, 2008 Forma ir noposteta! Ta ka esmu iesacejs php, nevareju isti saprast ka parbaudiit ar isset vai empty! Varbut var lugt isu uzmetumu!
didy Posted February 19, 2008 Author Report Posted February 19, 2008 (edited) Foruma vieta varetu ielikt saiti uz php.net un google.lv un varbuut uz wiki! Tas pats vien butu! Vareji jau njemt vera kad teicu "nevareju isti saprast ka parbaudiit ar isset vai empty" Meginaju ka paradiits isset() - nekada rezultata! Tadel jau nacu uz forumu pec palidzibas! Bet paldies! Gan jau tiku gala! Edited February 19, 2008 by didy
andrisp Posted February 19, 2008 Report Posted February 19, 2008 Būtu atvēris manuāli redzētu: if (isset($_POST['kautkas'])) { // daram lietas ar $_POST['kautkas'] }
didy Posted February 19, 2008 Author Report Posted February 19, 2008 Pateicos! Izradas ka biju darijis pareizi tikai nepamanijis, ka Undefined index problema parlekusi uz nakamo $var Izlaboju kludas! Paldies!
Recommended Posts