porzant Posted June 22, 2007 Share Posted June 22, 2007 Sorry about the stretching! Not sure how to fix it.I want to be able to store form inputs, so that a user can view them all. I think this may need an SQL database, but I'm not sure :S. If it does, can anyone suggest where I can get one free please .This is the HTML code for the form: <html><head><title>Porzant's Shoutbox</title></head><body><form action="http://porzant.awardspace.com/comment.php" method="post" onsubmit="settime()"><table><tr><td>Name: </td><td><input type="text" name="Name" maxlength="12" size="20" /></td><input type="hidden" name="Date" value="Set by Javascript function: settime(). Don't worry about that" /></tr><tr><td>Message: </td><td><input type="text" name="Message" maxlength="250" size="50" /></td></tr></table><input type="submit" value="Post Message" /></form></body></html> Here is the PHP code that its linking to: <?phpecho "<table width='600px'><tr><td valign='top' align='left' width='75px'>".$Name."<br />".$Date."</td><td width='25px'> </td><td valign='top' align='left'>".$Message."</td></tr></table>"?> To store the data from the form, I think it needs to be in a database, and then called as some kind of array. All help appreciated, thanks . Link to comment Share on other sites More sharing options...
shujjah Posted June 22, 2007 Share Posted June 22, 2007 yes to store information u need a database and then using the post method the information from the form is inputed into the database using some code Link to comment Share on other sites More sharing options...
porzant Posted June 22, 2007 Author Share Posted June 22, 2007 Ok, any idea of the code I'd need, or where I can get a database? Link to comment Share on other sites More sharing options...
shujjah Posted June 22, 2007 Share Posted June 22, 2007 what host u using? are u using a free one? Link to comment Share on other sites More sharing options...
porzant Posted June 23, 2007 Author Share Posted June 23, 2007 Yeah, don't have any host for a database at the moment though. Link to comment Share on other sites More sharing options...
shujjah Posted June 23, 2007 Share Posted June 23, 2007 go and search on google for a good free host that gives mysql etc i am sure there are many Link to comment Share on other sites More sharing options...
porzant Posted June 23, 2007 Author Share Posted June 23, 2007 Ok, I have a database.DB Host: fdb1.awardspace.comDB Name: porzant_shoutboxHow do I connect to it and make it store data from the form? Link to comment Share on other sites More sharing options...
MinusMyThoughts Posted June 24, 2007 Share Posted June 24, 2007 http://w3schools.com/php/php_mysql_connect.asp-Jason Link to comment Share on other sites More sharing options...
porzant Posted June 24, 2007 Author Share Posted June 24, 2007 So would I use a code like this? :NOTE: Fields from the form are called Name, Date, Message. $con=mysql_connect("fdb1.awardspace.com","porzant_shoutbox",password);INSERT INTO `shoutbox` ( `Name` , `Date` , `Message` ) VALUES ('$_POST[Name]', '$_POST[Date]', '$_POST[Message]'); ^ That would add the records to the database, if I'm correct? Does that go in the PHP file?To show them, would I use this? : mysql_select_db("porzant_shoutbox", $con);$result = mysql_query("SELECT * FROM table_name");while($row = mysql_fetch_array($result)) { echo $row['Name'] . " " . $row['Date']." ".$row['Message']; echo "<br />"; }mysql_close($con); Not really sure about those codes, any tips would be great . Link to comment Share on other sites More sharing options...
porzant Posted June 24, 2007 Author Share Posted June 24, 2007 Got it working now, so no need for any more help! Thanks ! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.