ryan.od Posted October 1, 2006 Share Posted October 1, 2006 I have a form that targets itself and is used to insert into a db. It works fine, but I want it to insert and then reload the form for another submission (with a little blurb telling them it inserted the last one successfully). Right now it will only do the IF part upon submission rather than the ELSE part.I am currently using the following code. Can I put another copy of the form in the 'IF' part? I tried that and it didn't work. Any suggestions would be appreciated!Thanks,Ryan--<html><head><title>Add New MySQL User</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body><?phpif(isset($_POST['add'])){include_once('db_connect.php');mysql_select_db ('evaluati_blog');$query = "INSERT INTO blog_main (title_main, intro_main, content_main) VALUES ('$title', '$intro', '$content')";$result = @mysql_query ($query);if($result) { echo 'Blog inserted! '; }else { echo 'Sorry'; }include 'db_close.php';}else{?><div id="wrapper"><form action="blog_submit.php" method="POST"><fieldset><legend>Article Submission</legend><div id="main"><table cellpadding="5" cellspacing="0" border="1"> <tr valign="bottom"> <td width="150" valign="bottom" > <label for="q8">Title <span class="required">*</span></label> </td> <td valign="bottom"> <input type="text" size="40" name="title" id="q8"> </td> </tr> <tr valign="bottom"> <td width="150" valign="bottom" > <label for="q9">Intro</label> </td> <td valign="bottom"> <input type="text" size="40" name="intro" id="q9"> </td> </tr> <tr valign="bottom"> <td width="150" valign="top" > <label for="q6">Blog<span class="required">*</span></label> </td> <td valign="bottom"> <textarea wrap="soft" cols="30" rows="8" name="content" id="q6"></textarea> </td> </tr> <tr valign="bottom"> <td width="150" valign="top" > <label for="q7">Category<span class="required">*</span></label> </td> <td valign="bottom"> <?php include_once('db_connect.php'); mysql_select_db ('evaluati_blog'); $query = "SELECT * FROM blog_category"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<input type=\"radio\" id=\"\" name=\"{$row['subject']}\" value=\"{$row['subject']}\">"; echo "{$row['subject']}<br />"; } include_once('db_close.php'); ?> </td> </tr> <tr valign="bottom"> <td width="150" valign="bottom" > </td> <td valign="bottom"> <input type="submit" name="add" id="add" value="Submit"> </td> </tr></table></div></fieldset></form></div><?php}?></body></html> Quote Link to comment Share on other sites More sharing options...
AndyB Posted October 1, 2006 Share Posted October 1, 2006 Then just lose the else structure. That way the form will submit, post data, and display again ready for the next time. 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.