andrew_biggart Posted February 28, 2009 Share Posted February 28, 2009 I know ive already posted this tonite so sorry but ive been at work and i cant find the post anywere lol But anyway what i want to do is on my form_page.php i dont want the code to run until the submit button has been pressed so that it does not submit empty data into the database as soon as the page loads, im sure theres a simple if statement but my pickled head can think atm lol. Im usuing this code. <div id="page_content_topic"> <table class="myprofile_change"> <tr><td class="myprofile_changesh"> <tr><td class="reg_status"> <?php include("config_members_temp.php"); $recipe_username=$_GET['username']; $recipe_title = ($_POST['recipe_title']); $recipe_ingre = ($_POST['recipe_ingre']); $recipe_method = ($_POST['recipe_method']); $recipe_cat = ($_POST['recipe_cat']); $sql = "INSERT INTO User_recipesT ( Recipe_username, Recipe_subject, Recipe_content, Recipe_ingre, Recipe_cat ) VALUES( '$recipe_username', '$recipe_title', '$recipe_method', '$recipe_ingre', '$recipe_cat' )"; $result=mysql_query($sql) or die(mysql_error().": $sql"); if($result){ echo "Your recipe has been successfully to our database"; } // if not found else { echo "Ops there has been a problem please go back and try again!"; } ?> </td></tr> </td></tr> </table> <form method="post" action="upload_recipe_submit.php?username=<? echo"".$_SESSION["myusername"]."" ?>"> <table class="myprofile_change"> <tr><td class="myprofile_changesh"> <img alt="Cooking cannabis : add a recipe" src="../Header_images/addrecipe.jpg" width="156" height="46" /></td></tr> <tr><td class="myprofile_subtext2">You are about to add a recipe to the weloveweed mansions achieve. Make sure that your recipe is as sensible as possible without being to dull. Even if its a recipe you have just made up and think that tastes good, add it anyway because other members might like it as well. Once your recipe has been submitted it may take 24hrs to show up as it has to be approved by one of our team.</td></tr> <tr><td></td></tr> </table> <br /> <table class="myprofile_change"> <tr><td class="myprofile_subtext">Recipe Title :</td><td class="style3"> <input name="recipe_title" type="text" /></td><td class="myprofile_max">Max 200 characters</td></tr> <tr><td class="myprofile_subtext">Recipe cat :</td><td class="style3"> <select name="recipe_cat" id="Fav"style="width: 126px"> <option>Choose</option> <option>Snack recipes</option> <option>Starter recipes</option> <option>Main course recipes</option> <option>Desert recipes</option> <option>Miscellaneous recipes</option> </select></td><td class="myprofile_max">Please select one</td></tr> <tr><td class="myprofile_subtext">Recipe ingredients :</td> <td class="style3"> <textarea name="recipe_ingre" style="width: 355px; height: 76px"></textarea></td><td class="myprofile_max">Max 400 characters<br /> Use <br /> to separate each ingredient.</td></tr> <tr><td class="myprofile_subtext">Recipe method :</td><td class="style3"> <textarea name="recipe_method" style="width: 355px; height: 190px" cols="20"></textarea></td><td class="myprofile_max"> Max 800 characters</td></tr> <tr><td></td></tr> <tr><td></td><td></td><td><input name="Reset1" type="reset" value="reset" /><input name="Submit1" type="submit" value="add that shit !" /></td></tr> <tr><td></td></tr> </table> <br /> </form> </div> Thanks in advance Quote Link to comment Share on other sites More sharing options...
ratcateme Posted February 28, 2009 Share Posted February 28, 2009 to find a post check your post history http://www.phpfreaks.com/forums/index.php?action=profile;area=showposts;sa=topics;u=65070 to fix your problem you want a if like this if(isset($_POST['Sumbit1'])){ around your insert code Scott. Quote Link to comment Share on other sites More sharing options...
andrew_biggart Posted February 28, 2009 Author Share Posted February 28, 2009 Thanks for your help firstly... ive tried this but i still have the same problem <?php include("config_members_temp.php"); $recipe_username=$_GET['username']; $recipe_title = ($_POST['recipe_title']); $recipe_ingre = ($_POST['recipe_ingre']); $recipe_method = ($_POST['recipe_method']); $recipe_cat = ($_POST['recipe_cat']); if(isset($_POST['Sumbit1'])){ $sql = "INSERT INTO User_recipesT ( Recipe_username, Recipe_subject, Recipe_content, Recipe_ingre, Recipe_cat ) VALUES( '$recipe_username', '$recipe_title', '$recipe_method', '$recipe_ingre', '$recipe_cat' )"; $result=mysql_query($sql) or die(mysql_error().": $sql");} if($result){ echo "Your recipe has been successfully to our database"; } // if not found else { echo "Ops there has been a problem please go back and try again!"; } ?> Quote Link to comment Share on other sites More sharing options...
ratcateme Posted February 28, 2009 Share Posted February 28, 2009 sorry i misspelled submit try changing it to Submit1 instead of Sumbit1 Scott. 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.