fdmagazine Posted August 9, 2007 Share Posted August 9, 2007 I want to setup a form that will put the field data directly into a webpage. I figure the script I need is similar to a forum script, but I can't seem to find a good one. Plus, the tutorials on forums at phpfreaks have been removed. The idea is to allow users of the site who are not code-savvy (or do not have Dreamweaver) to contribute (ironically the name of the software that allows this). Any ideas? Thanks in advance, Jon Quote Link to comment https://forums.phpfreaks.com/topic/64142-creating-a-direct-edit-form/ Share on other sites More sharing options...
frost Posted August 9, 2007 Share Posted August 9, 2007 It sounds like you want to have a running thread going? So one user posts something and then when the next guy posts something it shows under the other guys? You probably want to set up an sql database and store the posts in there, then read the sql to display them on your page. Quote Link to comment https://forums.phpfreaks.com/topic/64142-creating-a-direct-edit-form/#findComment-319730 Share on other sites More sharing options...
Fadion Posted August 9, 2007 Share Posted August 9, 2007 Basically u could create two pages, one ex. view.php and the other post.php. In view.php u could show all the posts and in post.php u could have a submit form. view.php <?php $query = @mysql_query("SELECT * FROM posts") or die(mysql_error()); while($values = mysql_fetch_array($query)){ echo "Posted by: " . $values['user'] . "<br />"; echo "Message: " . $values['text']; } ?> post.php <form name="form1" method="post" action=""> <input type="text" name="user" /> <input type="text" name="message" /> <input type="button" name="submit" value="Add" /> </form> <?php if(array_key_exists('text', $_POST)){ $user = mysql_real_escape_string($_POST['user']); $message = mysql_real_escape_string($_POST['message']); $date = date('m-d-y H:i:s'); if($user != "" and $message != ""){ $queryAdd = @mysql_query("INSERT INTO posts (user, message, date) VALUES('$user', '$message', '$date')") or die(mysql_error()); echo "Thank you for your time"; echo "<a href=\"view.php\">Return to View.php</a>"; } else{ echo "Please fill in all the fields"; } } ?> And u may have a database with fields like: user, message, date. Quote Link to comment https://forums.phpfreaks.com/topic/64142-creating-a-direct-edit-form/#findComment-319751 Share on other sites More sharing options...
Fadion Posted August 9, 2007 Share Posted August 9, 2007 And consider that was just a quick not tested code, but which should give u an idea of how it works. Quote Link to comment https://forums.phpfreaks.com/topic/64142-creating-a-direct-edit-form/#findComment-319757 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.