Page 1 of 1

display problem

Posted: Sun Aug 15, 2004 10:37 pm
by Think Pink
hello.I have a question.
I have something like this :

Code: Select all

<?php
<table>
<tr>
<td>
<form name="test" action="<? $PHP_SELF; ?>" method="post">
test1<br>
<input type="text" name="test1"><br>
test2<br>
<input type="text" name="test2"><br>

<input type="submit" name="add">
</form>
</td>
</tr>

<tr>
 <td>
  <?php
   bla bla bla
    
    if(isset($_POST['add']))	{
     $sql = "select.....
     ...
         if (mysql_num_rows($result) != 0) {
            print "This allready exists";
            exit;
         }
         $sql = "INSERT ...
         .....
            print "Added succesfully";
            exit;
   }
  ?>
 </td>
</tr>

<tr>
 <td>Some thext very important </td>
</tr>
</table>
?>
after the form is submitted the page reloads and it tels me if the input is allready in the $db or not. If it is, or not the execution stops and the problem is that the text that is after the script it doesn't appear anymore. The script has to be in that position because the message it prints out belongs to some fields I have there.

Question :
How can I make that the info the script prints out appear in the position I want, and in the same time the info after the script appear where I want it on the page (after the info the script prints)?

This is how I want it to be
Short version


input 1
input 2
submit button
message script prints out
information after the script. a picture or whatever

Re: display problem

Posted: Sun Aug 15, 2004 11:31 pm
by Buddha443556
Do the processing first.

Code: Select all

<?php
   bla bla bla
  
$message = "";  
    if(isset($_POST['add']))	{
     $sql = "select.....
     ...
         if (mysql_num_rows($result) != 0) {
            $message = "This allready exists";
         }
         $sql = "INSERT ...
         .....
            $message = "Added succesfully";
   }
  ?>

<table>
<tr>
<td>
<form name="test" action="<? $PHP_SELF; ?>" method="post">
test1<br>
<input type="text" name="test1"><br>
test2<br>
<input type="text" name="test2"><br>

<input type="submit" name="add">
</form>
</td>
</tr>

<tr>
 <td>

  <?php echo $message; ?>

 </td>
</tr>

<tr>
 <td>Some thext very important </td>
</tr>
</table>
?>

Posted: Tue Aug 17, 2004 2:52 pm
by Think Pink
thx, is working, but now it inserts the data in the db even if the data is allready entered.

but I inserted an "else" and works great.