mysql - how to display the result after the submit php form -
how display result after submit form
i want display result after submit form print
example 1st im filling form submit result after submit want screen display same result http://www.tizag.com/phpt/examples/formexample.php
how can please me fix issue.
php form code
<?php function renderform($grn, $name, $rollno, $class, $fees, $date, $reference, $error) { ?> <?php if ($error != '') { echo '<div style="padding:4px; border:1px solid red; color:red;">'.$error.'</div>'; } ?> <form action="" method="post"> <div> <p><span class="style9"><strong>g.r.n no:</strong></span><strong> *</strong> <input name="grn" type="text" id="grn" value="<?php echo $grn; ?>" size="50" /> </p> <p><span class="style9"><strong>name:</strong></span><strong> *</strong> <input name="name" type="text" id="name" value="<?php echo $name; ?>" size="50" /> </p> <p><span class="style9"><strong>roll no :</strong></span><strong> *</strong> <input name="rollno" type="text" id="rollno" value="<?php echo $rollno; ?>" size="50" /> </p> <p><span class="style9"><strong>class:</strong></span><strong> *</strong> <input name="class" type="text" id="class" value="<?php echo $class; ?>" size="50" /> </p> <p><span class="style9"><strong>fees date :</strong></span><strong> *</strong> <input id="fulldate" name="date" type="text" value="<?php echo $date; ?>" size="50" /> </p> <p><span class="style9"><strong>fees :</strong></span><strong> *</strong> <input name="fees" type="text" value="<?php echo $fees; ?>" size="50" /> </p> <span class="style9"><strong>reference</strong></span><strong> *</strong> <input name="reference" type="text" value="<?php echo $reference; ?>" size="50"> <br/> <p class="style1">* required</p> <input type="submit" name="submit" value="submit"> </div> </form> <?php } include('connect-db.php'); if (isset($_post['submit'])) { // form data, making sure valid $grn = mysql_real_escape_string(htmlspecialchars($_post['grn'])); $name = mysql_real_escape_string(htmlspecialchars($_post['name'])); $rollno = mysql_real_escape_string(htmlspecialchars($_post['rollno'])); $class = mysql_real_escape_string(htmlspecialchars($_post['class'])); $fees = mysql_real_escape_string(htmlspecialchars($_post['fees'])); $date = mysql_real_escape_string(htmlspecialchars($_post['date'])); $reference = mysql_real_escape_string(htmlspecialchars($_post['reference'])); // check make sure both fields entered if ($grn == '' || $name == '' || $rollno == '') { // generate error message $error = 'error: please fill in required fields!'; // if either field blank, display form again renderform($grn, $name, $rollno, $class, $fees, $date, $reference, $error); } else { // save data database mysql_query("insert fees set grn='$grn', name='$name', rollno='$rollno', class='$class', fees='$fees', date='$date', reference='$reference'") or die(mysql_error()); echo "<center>keyword submitted!</center>"; // once saved, redirect view page } } else // if form hasn't been submitted, display form { renderform('','','','','','','',''); } ?>
not quite shure asking.
do need displaying submited form data? or more spesific display print?
to display need make html
page displays it. like:
echo '<table><tr>'; echo '<td>'; echo '<strong>name:</strong><br/>'; echo $name; echo '</td>'; echo '</tr></table>';
to display result , not form, when post same page need encapsulate code if statement.
if(isset($_post['submit'])) { //code php form }else { //code display form }
Comments
Post a Comment