Jump to content

problem with adding to the database


Goldi90

Recommended Posts

Hi,

how to make this form + php to make it work this way

 

from the drop-down box choose the database title, or ID, and then the form in which I write some content will be added to the database that matches the title or ID that is sometimes so as not to invade a mistake and content that I type is not added to another title or ID

 

I created something like this:

 

<?php
$db = new mysqli('localhost','xxxxx','xxxx','xxxx');
mysqli_query($db,'SET NAMES `utf8`');
$sqlnowe = mysqli_query($db,'SELECT * FROM `cc` ORDER BY `id` DESC  ');

		?>

<form action="formu.php" method="post">
<select name="tytul">
<?php while ($rownowe = mysqli_fetch_array($sqlnowe)) { ?>
	<option><? echo $rownowe['tytul']; ?></option><?php };?>

</select>


opismax:<br />
<input type="text" name="opismax" /><br />
<textarea name="opismax" cols="50" rows="10">Proszę, wpisz tutaj jakiś komentarz...</textarea>

<input type="submit" value="dodaj" />
</form>

<?php

// odbieramy dane z formularza
$tytul = $_POST['tytul'];
$opismax = $_POST['opismax'];

if($tytul and $opismax) {
    
   
    
    // dodajemy rekord do bazy
    $ins = mysqli_query("INSERT tytul='$tytul' INTO publications SET  opismax='$opismax'");
    
    if($ins) echo "Good";
    else echo "Bad";
    

}

?>

 

Link to comment
https://forums.phpfreaks.com/topic/224708-problem-with-adding-to-the-database/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.