Jump to content

Need Help With Submission Denial


elite_prodigy

Recommended Posts

I'm attempting to build a submission device for users. It's working perfectly, without any errors, I just can't think of an effective way to give the ability to deny a submission.

 

 

<?php
$get_articles = "SELECT id, title, alias, article FROM dirt_digger_submit;";
$get_articles_res = mysql_query($get_articles,$conn) or die(mysql_error());



while ($article_info = mysql_fetch_array($get_articles_res)) {
$id = $article_info[id];
$alias = $article_info[alias];
$title = $article_info[title];
$article = $article_info[article];

$display_dirt .= "
<form method=\"post\" action=\"approve_dirt.php\">
Alias Used:<input type=\"text\" name=\"alias\" value=\"$alias\" /><br />
Title Given:<input type=\"text\" name=\"title\" value=\"$title\" /><br/>
Article Submited:<br /><textarea name=\"article\" rows=\"10\" cols=\"50\" wrap=\"virtual\">$article</textarea><br />
<input type=\"hidden\" value=\"$id\" name=\"id\" />
<input type=\"submit\" name=\"submit\" value=\"Approve\" />
<input type=\"reset\" name=\"reset\" value=\"Deny\" />
</form>
";
}
?>

 

...extracts the articles from the database directly into the forms. And displays them so they can be edited if need be for grammar, spelling and what not.

 

 

<?php
//adds the article to the new database
$approve_article = "INSERT INTO dirt_digger VALUES ('', '$_POST[alias]', '$_POST[title]', '$_POST[article]');";
mysql_query($approve_article,$conn) or die(mysql_error());

//deletes the article as I don't need two copies
$remove_article = "DELETE FROM dirt_digger_submit WHERE id = {$_POST['id']};";
mysql_query($remove_article,$conn) or die(mysql_error());

header("location:dirt.php");
?>

 

...moves the approved article to a sepparate database from where it is pulled and placed on the web site.

 

Now, my problem is I want to be able to deny the post. But the only method I can think of is using the clear button and coding a condition like:

 

<?php

if(isset($_POST[article]) & isset($_POST[title]) & isset($_POST[alias])){
//move and delete the record
}

else{
//just delete the record
}

?>

 

Could anyone help me with this?

Link to comment
https://forums.phpfreaks.com/topic/98398-need-help-with-submission-denial/
Share on other sites

which is ???

 

if you want your reset button to work properly either dont use doubles in your inputs along with backslashes or use singlequotes. :P

 

$display_dirt .= "
<form method=\"post\" action=\"approve_dirt.php\">
Alias Used:<input type=\"text\" name=\"alias\" value=\"$alias\" /><br />
Title Given:<input type=\"text\" name=\"title\" value=\"$title\" /><br/>
Article Submited:<br /><textarea name=\"article\" rows=\"10\" cols=\"50\" wrap=\"virtual\">$article</textarea><br />
<input type=\"hidden\" value=\"$id\" name=\"id\" />
<input type=\"submit\" name=\"submit\" value=\"Approve\" />
<input type=\"reset\" name=\"reset\" value=\"Deny\" />
</form>
";

 

The above is PHP. You HAVE to use \ to escape it.

no you dont it works the same with or without the backslashesand doublequotes

 

try the following:

 

<?php
$display_dirt .= "
<form method=post action=approve_dirt.php>
Alias Used:<input type=text name=alias value=$alias><br>
Title Given:<input type=text  name=title value=$title><br>
Article Submited:<br><textarea name=article rows=10 cols=50 wrap=virtual>$article</textarea><br>
<input type=hidden value=$id name=id>
<input type=submit name=submit value=Approve>
<input type=reset name=reset value=Deny>
</form>
";?>

no you dont it works the same with or without the backslashesand doublequotes

 

Really?

 

Copy the above code into a PHP document and remove the backslashes(leave doublequotes). Then try and load the page.

 

The error you will get will read as follows. (or similarly)

 

Error: Unexpected T_STRING in home/.../.../.../*.php on line ##

 

When using double quotes in a PHP string they must be escaped when a double quote is used after the = sign.

for ex:

<?php
$varname = " HEllo, world. Joe says: \"HEllo\""; // escape double quotes
$varname = ' HEllo, world. Joe says: \'HEllo\''; // escape single quotes
?>

 

I've tried that. Also, is it not good HTML coding practice to quote all atribute values?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.