Hi to all,
The code below shows to upload a content in to the database.
My problem is, i have to create two users, one should login into the page and upload the conntent and the other should login into the page and approve it to display in the site.
So can anyone please reply and post a code for me to dowload and approve it or any other way to do it.

Note:- This is mainly used for news updates.

I appreciate, if anyone gives the solution for this

Thank You,
Ronnjoe

<html>
<body>
<?php
mysql_connect("localhost", "root", "") or die(mysql_error());
//echo "Connected to MySQL<br />";
mysql_select_db("User_info") or die(mysql_error());
//echo "Connected to Database<br /><br />";

?>
<form action="/forums/form.php" method="post">
Name: <input type="name" name="name" />
Content: <input type="text" name="cont" />
<input type="submit" />
</form>

 <?php
 $name= $_POST['name'];
 $content=$_POST['cont'];
 mysql_query("INSERT INTO news (Name, Content, Status)
 VALUES ('$_POST[name]','$_POST[cont]','pd')");
?> 

</body>
</html>
Member Avatar for diafol

This is how I'd do it - but there are a few methods:

The approvals page should be visible to the dedicated "approver". So, on open approvals page, do the following:

1) Check that the current user (check via sessions - the security level of the user, e.g. 0 is guest, 1 = user, 2 = approver, 3 = superadmin or similar). If userlevel < 2 bounce them to the page they came from ($_SERVER) - or if not from your domain, send them to the homepage.

2) List all unapproved postings in a table:

ID TITLE USER (from) DATE (posted) VIEW/EDIT(link to edit/view)

3) Once link hit to edit - go to new page with form - fill inputs/textboxes with info from the posting to edit. Approver has three buttons : APPROVE + DECLINE + CANCEL

The approve will update the record and change the status to approved + send approver back to approvals page.
The declined will update the status to declined + send approver back to approvals page
The cancel button will just send approver back to approvals page - no edits.

4) Because the approvals page only lists 'pending' posts, any newly approved or declined posts will not now feature.

BTW: If a post is declined, it would be polite for the approver to include a message in a field (e.g. decline_msg), so that the poster could see why his/her post was not included.

hi ardav,
Thank you very much for the suggestion.

But i need a code for that. can u send it plz


By Ronnjoe

Member Avatar for diafol

Don't take this the wrong way, but:

1) you've just joined + haven't had the opportunity to make a contribution to the forum
2) you want me or somebody else to write some custom code that would meet your needs.
3) You've made no attempt yourself to address a number of the issues raised in your post, or at least have not displayed these attempts.

Could I suggest that you have a stab at this yourself in the first instance, using my suggestions or those of others or from ideas gleaned from other sources. Then, if in difficulty, post your code and we could help you with certain areas.

If this work is to be used in an 'assessment', be aware that you may not be allowed to use any work contributed by others. Other members have been distraught when they published their code on forums like this, to be told that they were no longer allowed to use it.

You may Use The Below Specified Code:

form.php //for Uploading Contain in Database by User.

<html>
<body>
<?php
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("User_info") or die(mysql_error());
?>
<form action="/forums/form.php" method="post">
Name: <input type="name" name="name" />
Content: <input type="text" name="cont" />
<input type="submit" />
</form>
 
 <?php
 $name= $_POST['name'];
 $content=$_POST['cont'];
if (isset($_POST['submit']))
{
 $query = mysql_query("INSERT INTO tbl_name (Name, Content, Status) VALUES ('$name','$content','NO')");
 if (!$query)
 {
 	echo "Sorry! There are an Error. Please Try Again";
 }
 else
 {
 	echo "Your Content Successfully Submitted for Administrator Approval.";
 }
}
?> 
 
</body>
</html>

validation.php //for Validating the User Contain.

<html>
<body>
<p>
  <?php
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("User_info") or die(mysql_error());
?>
  <table width="100%" border="1">
  <tr>
    <td><b>Name</b></td>
    <td><b>Content</b></td>
    <td><b>Validation</b></td>
  </tr>
  <?php
  //the below section for feching the Validation Data.
  $query = mysql_query("SELECT * FROM tbl_name WHERE Status = 'NO'");
 while ($row = mysql_fetch_array($query))
 {
 	$name = $row['Name'];
	$Content = $row['Content'];
	$id = $row['ID'];
 	echo "<form action=\"validate.php\" mathod=\"POST\"><tr>
    <td>$name</td>
    <td>$Content</td>
    <td><input type=\"hidden\" name=\"id\" value=\"$id\"><input type=\"submit\" name=\"Submit\" value=\"Validate\"></td>
  </tr></form>";
 }
?> 
</table>
<?PHP
//The below code for validating details.
$id = $_POST['id'];
if (isset($_POST['Submit']))
{
	$query = mysql_query("UPDATE tbl_name SET Status = 'YES' WHERE id = '$id'");
	if (!$query)
 {
 	echo "Sorry! There are an Error. Please Try Again";
 }
 else
 {
 	echo "Your Content Successfully Approved and Published on Website.";
 }
}
?>
</body>
</html>

If You face any Problem in Above Code Then Post Your Problem Here. I Will Heling You.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.