Hello,
I'm kind of new to this so I'm not sure where i'm going wrong.
I'm trying to write to my SQL db using the following php code:
<?php
$date = $_POST['date'];
$story = $_POST['story'];
$db_host = "localhost";
$db_user = "MyUsername";
$db_pwd = "password";
$db_name = "db_name";
mysql_connect($db_host, $db_user, $db_pwd);
mysql_select_db($db_name);
mysql_query("INSERT INTO news (date, story) VALUES ($date, $story)");
echo "Your news story has been added!";
?>
here is my html form code as well:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<div align="center">
<form id="form1" name="form1" method="post" action="submit.php">
<label>Date
<input type="text" name="date" id="date" />
</label><p>
<label>Story
<textarea name="story" id="story" cols="45" rows="20"></textarea>
</label><p align="center">
<input name="submit" type="submit" value="+Submit+" />
</form>
</div>
</body>
</html>
when i hit the submit button on from my form, i get the echo text, but it does not write the text from the forms into my db.
the db table is set up correctly and i manually added some entries using phpMyAdmin. I'm able to access those entries using another php file the writes it in XML.
any ideas?
thanks