Pentiums Posted February 11, 2008 Report Share Posted February 11, 2008 <?php echo "<center><br><br><br><br><form method='post' action='".$PHP_SELF."'> Virsraksts:<input type='text' name='$title' value=''> <br>Teksts:<extarea name='text' rows='10' cols='50' align=center></textarea><br> <input type='submit' value='Pievienot!'></form></center>"; if ($action == $PHP_SELF) { mysql_query("INSERT INTO `latviski`.`raksti` (`id`, `nosaukums`, `teksts`, `datums`, `kaukas`) VALUES (NULL, '".$_POST['title']."', '".$_POST['text']."', NOW(), '');"); } ?> Kapēc šis skripts postē datubāzē jau tad, kad es tikai palaižu skriptu? Man vajag tā, lai viņš iepostē tikai formu saturu, kad nospiežu Pevienot.. Help :) Link to comment Share on other sites More sharing options...
Vebers Posted February 11, 2008 Report Share Posted February 11, 2008 (edited) Ifs izskatīsies šādi: if(!empty($_POST[$title]) && !empty($_POST['text'])) Edited February 11, 2008 by Vebers Link to comment Share on other sites More sharing options...
Aleksejs Posted February 11, 2008 Report Share Posted February 11, 2008 Pirms tā if($action... testa nolūkos izdari: echo('|'.$action.'|<br>'); echo('|'.$PHP_SELF.'|<br>'); un izdari secinājumus. ;) Hint #1: Neraksti ar register_globals Hint #2: Nosūtot formu netiek uzstādīts tāds mainīgais "action" Link to comment Share on other sites More sharing options...
Pentiums Posted February 11, 2008 Author Report Share Posted February 11, 2008 if(!empty($_POST[$title]) && !empty($_POST['text'])) nekas neizmainījās un kā tad uzstādīt to $action mainīgo? un kā tad būs bez register globals? Link to comment Share on other sites More sharing options...
Aleksejs Posted February 11, 2008 Report Share Posted February 11, 2008 <input type="hidden" name="action" value="1"> $_POST['action'] Link to comment Share on other sites More sharing options...
Pentiums Posted February 11, 2008 Author Report Share Posted February 11, 2008 paldies ;) samūķēju kautkā un sanāca viss :) Link to comment Share on other sites More sharing options...
Recommended Posts