winmastergames Posted February 2, 2009 Share Posted February 2, 2009 This Should Work: opdater.php <?php $host = "localhost"; $user = "twossdow_magie"; $pass = "280788"; $mb = "twossdow_magie2"; $db = mysql_pconnect($host, $user, $pass); mysql_select_db($mb,$db); if(trim($_POST["navn"]) == "please fill this out") $sql = "INSERT INTO indlaeg (`navn`,`email`,`besked`) " ."VALUES ('".$_POST['navn']."', '".$_POST['email']."', '".$_POST['besked']."')"; $result = mysql_query($sql); echo $sql; ?> <html> <title>Opdater</title> <body bgcolor="#FFFFFF"> Tak for det. <a href="laes.php">Klik for at vende tilbage til gæstebogen.</a> </body> </html> laes.php <html> <title>Gæstebog</title> <body bgcolor="#FFFFFF"> <form name="form1" method="post" action="opdater.php"> Læg venligst en besked <br> Navn: <input type="text" name="navn" id="navn"> <br> Email: <input type="text" name="email" id="email"> <br> Besked: <textarea name="besked" rows="8" id="besked"></textarea> <input type="submit" name="Submit" value="Indsend"> </form> <hr> Tak til de personer, som allerede har lagt en besked! <hr> <?php $host = "localhost"; $user = "twossdow_magie"; $pass = "******"; $mb = "twossdow_magie2"; $db = mysql_pconnect($host, $user, $pass); mysql_select_db($mb,$db); $result = mysql_query("SELECT * FROM indlaeg",$db); while ($myrow = mysql_fetch_row($result)){ ?> Navn: <? echo $myrow[1] ?> <br> Email: <? echo $myrow[2] ?> <br> Besked: <? echo $myrow[3] ?> <br> <hr> <? } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/143368-mysql-insert-into-help/page/2/#findComment-752314 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.