andrew_biggart Posted February 27, 2009 Share Posted February 27, 2009 Im trying to make a form page post to it self when it is submitted, but i im having a few problems, when the page first loads it displays an error message as if the form has tried to be submitted which isnt what i want, how do i tell it not to run the php until the submit button has been pressed? im using the following code for the form and php <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> Thankyou in advance 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.