Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3
  1. #1
    Junior Member
    Join Date
    Sep 2017
    Posts
    1
    Member #
    57343

    Multiple PHP actions on one form

    Hi there,

    I am writing a website for a friend. The goal is to allow people to write and submit poetry to help with depression and anxiety, provide messages of hope and things like that. I have created most of the website, but one section has got me stumped.

    What I want to implement is an approval process, where submitted poetry is segregated until reviewed and approved, given the proliferation of online trolls around such things. What I want to achieve is to have a form where a piece is reviewed with radio button selections for "approve" or "delete", and this is where I have stalled.

    This is what I have created:

    review.php
    HTML Code:
    <!DOCTYPE html>
    <html>
    	<head>
    	<title>Soul's Fire - Review Submissions</title>
    	</head>
    	<body background="Images/background.png">
    		<center><img src="Images/heading.png"></center>
    		<h1 align="center"><font color="#cc9900">Soul's Fire - Review Submissions</font></h1>
    		<p align="center">Words go here</p>
    		<?php
    			error_reporting(E_ALL & ~(E_WARNING));
    			$dbconnect=mysqli_connect("127.0.0.1","user","password","poems");
    			$result=mysqli_query($dbconnect, "SELECT * FROM submissions WHERE Approved='N' ORDER BY Time_Submit LIMIT 1");
    			if ($row=mysqli_fetch_array($result))
    			{
    			echo "<form action='adddel.php' method='post'>\n";
    			echo "<div align='center'>\n";
    			echo "<table border=1 width='80%'>\n";
    			echo "<caption align='bottom'><p><input type='submit' name='AppDel' value='Submit Approval'></caption>\n";
    			echo "<tr><th width='10%'>Author</th><th width='15%'>Title</th><th width='15%'>Time Submitted</th><th width='*'>Entry</th></tr>\n";
    			do
    				{
    				printf("<tr><td align='center'>%s</td><td align='center'><b>%s</b></td><td align='center'>%s</td><td>%s</td></tr>\n",
    				$row["Author"], $row["Title"], $row["Time_submit"], $row["Entry"]);
    				}
    			while ($row=mysqli_fetch_row($result));
    			echo "<tr><td colspan='4' align='center'><INPUT TYPE='radio' NAME='ConApprove' VALUE='Approve'>Approve Submission
    			<br><INPUT TYPE='radio' NAME='ConApprove' VALUE='Delete'>Delete Submission</td></tr>\n";
    			echo "</table></div><br></form>\n";
    			echo "<p align='center'><a href='#top'>Back to Top</a></p>";
    			}
    	   	else
    			{
    			echo "No entries to review.";
    			}
    		?>
    		<div align="center">
    		<A HREF="index.php">Return to the main page</A>
    		</div>
    		<h1 align="center"><font color="#cc9900">If you would like me to add content down here, let me know</font></h1>
        </body>
    </html>
    adddel.php
    PHP Code:
    <?php
        $error
    ="";
        
    $go=TRUE;

        
    $dbconnect=mysqli_connect("127.0.0.1""user""password""poems");
        if(!
    $dbconnect)
            {
            die(
    'Unable to connect to database.');
            }

        
    $AppDel=$_POST["ConApprove"];

        if(
    $AppDel=="Approve")
            {
            
    $message .="This will approve the submission. Continue?\\n";
            
    $ApproveSet=("UPDATE submissions SET Approved='Y' WHERE ID=$row['ID']");
            }
        elseif(
    $AppDel=="Delete")
            {
            
    $message .="This will delete the submission. Continue?\\n";
            
    $ApproveSet=("DELETE FROM submissions WHERE ID=$row['ID']");
            }
        else
            {
            
    $error .="Please select before continuing\\n";
            
    $go=FALSE;
            }

        if(
    $go==TRUE)
            {
            echo (
    "<script language='JavaScript'>message('$message');</script>");
            
    mysqli_query($dbconnect$ApproveSet) or die(mysqli_error());
            echo 
    "<A HREF='review.php'>Return to review page</A>\n";
            }
        else
            {
            echo (
    "<script language='JavaScript'>alert('$error');</script>");
            echo (
    "<script language='JavaScript'>javascript:history.go(-1)</script>");
            }
    ?>
    But when I select any option I only receive an error message (see attachment).

    I am only just recently getting back into website design after about 15 years, so my knowledge is pretty archaic and rudimentary. I have created basic forms for this website, which work with no problem, but this one is probably too ambitious for my limited knowledge.

    Thank you in advance.
    Attached Images Attached Images

  2.  

  3. #2
    Junior Member SoftLink's Avatar
    Join Date
    Sep 2017
    Location
    Central Florida
    Posts
    24
    Member #
    57480
    Yea, you've got a mess there.
    In view of the fact that a poem will take up a lot of the page, I'd display them 1 at a time with an Approve and a Reject button at the top & bottom.

    I'd pull up the first full record and display it with the Approve, Reject buttons.
    When they click either button I'd handle the database work for the record they viewed (approve or delete or . . . ) and then pull up the next record.


    --------------------------------------------------------------------------------------------------------------------------------
    Business Software • Database • Internet • Websites
    Web Designers: Need some heavy lifting done?
    SoftLink Systems

  4. #3
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,414
    Member #
    5580
    Liked
    682 times
    I can't see what the error message is in your small fuzzy image.
    Maybe you can post the actual error text?

    It would so easy to just use a pre-made wordpress template:
    https://codecanyon.net/item/accesspr...st-pro/9160446
    Last edited by mlseim; Oct 23rd, 2017 at 06:03 PM.



Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Tags for this Thread

All times are GMT -6. The time now is 09:52 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com