hi,
it is giving me headache to write data from a php file to mysql( i can read from the table but cant write) here is my connect.php which connects to mysql:
<?php
$mysql_host = "localhost";
$mysql_user = "sam";
$mysql_pass = "123456";
$mysql_data = "website";
$mysql_table = "shoutbox";
mysql_connect($mysql_host,$mysql_user,$mysql_pass) or die("Couldnt connect, try again. " . mysql_error());
mysql_select_db($mysql_data) or die("Cannot select database! Please Try again." . mysql_error());
?>
here is the php file that should write it to table:
<html>
<head><title></title></head>
<body>
<?
include("connect.php");
if ($_POST['submit']) {
$name = $_POST['name'];
$url = $_POST['url'];
$message = $_POST['message'];
$date = date('jS \o\f F, Y \a\t g\:iA');
$ip = $_SERVER['REMOTE_ADDR'];
if (!$name || !$message) {
die ('You left a field blank. Please check again.');
}
else {
mysql_query("INSERT INTO shoutbox (id,ip,name,url,message,date) VALUES('','$ip','$name','$url','$message','$date')") or die('Error inserting into DB.');
}
}
?>
<form name="shout" method="post" action="process.php">
<div align="center"><iframe height="200" width="120" src="show.php" name="shoutbox"></iframe>
<br>
Name:<br>
<input name="name" type="text" size="15" style="border: solid 1px #000000; font: Verdana; font-size: 10px; background: #f8f8f8;">
<br>
URL:<br>
<input name="url" type="text" size="15" style="border: solid 1px #000000; font: Verdana; font-size: 10px; background: #f8f8f8;">
<br>
Message:<br>
<textarea name="message" cols="15" wrap="VIRTUAL" style="border: solid 1px #000000; font: Verdana; font-size: 10px; background: #f8f8f8;"></textarea>
<br>
<input type="submit" name="Submit" value="Submit" style="border: solid 1px #000000; font: Verdana; font-size: 10px; background: #f8f8f8;">
</div></form>
</body>
</html>
can anyone please point out my mistake.
thank you