elite_prodigy Posted March 28, 2008 Share Posted March 28, 2008 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? Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted March 28, 2008 Share Posted March 28, 2008 might wanna try <?php if(!empty($variable)){ ?> Quote Link to comment Share on other sites More sharing options...
elite_prodigy Posted March 28, 2008 Author Share Posted March 28, 2008 I can't get the reset attribute on the button to work. Thanks for you help! Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted March 28, 2008 Share Posted March 28, 2008 try taking the backslashes out! Quote Link to comment Share on other sites More sharing options...
elite_prodigy Posted March 28, 2008 Author Share Posted March 28, 2008 try taking the backslashes out! If I take out the backslashes then I get a T_STRING error. They are needed to escape the " character. Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted March 28, 2008 Share Posted March 28, 2008 take out the doublequotes in the inputs and the backslashes problem solved Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted March 28, 2008 Share Posted March 28, 2008 Yep. as a rule, i always use single quotes inside HTML elements <IMG SRC='somefile.jpg' HEIGHT='30' WIDTH='30' ALT='some text' BORDER='0'> Quote Link to comment Share on other sites More sharing options...
elite_prodigy Posted March 28, 2008 Author Share Posted March 28, 2008 The type of quotes should have no bearing on what I'm trying to accomplish. Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted March 28, 2008 Share Posted March 28, 2008 which is ??? if you want your reset button to work properly either dont use doubles in your inputs along with backslashes or use singlequotes. Quote Link to comment Share on other sites More sharing options...
elite_prodigy Posted March 28, 2008 Author Share Posted March 28, 2008 which is ??? if you want your reset button to work properly either dont use doubles in your inputs along with backslashes or use singlequotes. $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. Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted March 28, 2008 Share Posted March 28, 2008 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> ";?> Quote Link to comment Share on other sites More sharing options...
elite_prodigy Posted March 28, 2008 Author Share Posted March 28, 2008 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? Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted March 28, 2008 Share Posted March 28, 2008 did you try my code? no i dont think you did! who cares this is not a html help forum this is a php help forum and i think anyone here would tell you i am doing the right thing! Quote Link to comment Share on other sites More sharing options...
elite_prodigy Posted March 28, 2008 Author Share Posted March 28, 2008 Yes, I have. The form still does not clear when clicking the reset button. Quote Link to comment 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.