Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/64142-creating-a-direct-edit-form/
Share on other sites

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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.