Penguin
Fledgling Freddie
- Joined
- May 11, 2005
- Messages
- 375
Hey Folks,
I'm setting up a news system on my website using php and mysql and it's proving rather tricky, i'm hoping someone out there can help me
Basically the user logs into a password protected page which contains a form with sevral fields for the user to fill in (Title, Date, Content, that kind of thing)
I'm rather new to PHP but after reading a gazillion tutorials and guides especially on PHP with MYSQL i came up with this:
The user clicks submit and moves onto newsprocess.php:
I did fill in the database name, username and password.
I've setup the database the table and the fields. Would what "type" the fields are perhaps be a problem?
I did test it, entered the data, clicked submit, all seemed well except my table remained empty This data would later be retrieved and displayed on the home page, if ofcourse i could get it to work
Any help much appreciated.
- Penguin.
I'm setting up a news system on my website using php and mysql and it's proving rather tricky, i'm hoping someone out there can help me
Basically the user logs into a password protected page which contains a form with sevral fields for the user to fill in (Title, Date, Content, that kind of thing)
I'm rather new to PHP but after reading a gazillion tutorials and guides especially on PHP with MYSQL i came up with this:
Code:
<form method="post" action="newsprocess.php" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="0" name="memeberparent" >
<tr><td bgcolor="#000000">
<table width="100%" border="0" cellspacing="1" cellpadding="10">
<tr bgcolor="#708090">
<td bgcolor="#708090"><font face="verdana" size="2"><center>Title:</center></font></td>
<td bgcolor="#708090"><font face="verdana" size="2"><input type="text" wrap="physical" name="title"></font></td>
</tr>
<tr bgcolor="#708090">
<td bgcolor="#708090"><font face="verdana" size="2"><center>Time:</center></font></td>
<td bgcolor="#708090"><font face="verdana" size="2"><input type="text" wrap="physical" name="datetime">
<!-- PHP Time/Date -->
<?php
print date("l M dS, Y, H:i:s")
?></font></td>
</tr>
<tr bgcolor="#708090">
<td bgcolor="#708090"><font face="verdana" size="2">Content:</center></font></td>
<td bgcolor="#708090"><font face="verdana" size="2">
<textarea rows="20" cols="60" wrap="physical" name="content">
Enter News Here
</textarea></center></font></td>
</tr>
<tr bgcolor="#708090">
<td bgcolor="#708090"><font face="verdana" size="2"><center>Submit:</center></font></td>
<td bgcolor="#708090"><font face="verdana" size="2"><center>
<input type="submit" value="Submit News"></form></center></font></td></tr></table>
</center>
</td>
</tr>
</table>
<br><br><br><br>
</td>
</tr>
The user clicks submit and moves onto newsprocess.php:
PHP:
<?php
$title = $_POST['title'];
$content = $_POST['content'];
$datetime = $_POST['datetime'];
$conn = mysql_connect("localhost", "USERNAME", "PASSWORD");
//select db
$select = mysql_select_db("DATABASENAME");
//query
$query = "INSERT INTO TABLENAME VALUES ('','$title','$datetime','$content')";
mysql_close($conn);
?>
I did fill in the database name, username and password.
I've setup the database the table and the fields. Would what "type" the fields are perhaps be a problem?
I did test it, entered the data, clicked submit, all seemed well except my table remained empty This data would later be retrieved and displayed on the home page, if ofcourse i could get it to work
Any help much appreciated.
- Penguin.