tags:

views:

40

answers:

2

I have this html form which will then it will call addstuds.php to execute the code for inserting records in mysql database.

    <form name="formcheck" method="post" action="addstuds.php">
<td width="30" height="35"><font size="3">*I D Number:</td>
<td width="30"><input  name="idnum" onkeypress="return isNumberKey(event)" type="text" maxlength="5" id='numbers'/></td>
</tr>

<tr>
<td width="30" height="35"><font size="3">*Year:</td>
<td width="30"><input  name="yr" onkeypress="return isNumberKey(event)" type="text" maxlength="5" id='numbers'/></td>

<td width="30" height="35"><font size="3">Section:</td>
<td width="30"><input  name="sec"  type="text" maxlength="15"></td>
</tr>

What do I need to do so that the regstuds.php(html form) will be the one that will be seen again after the insert code in addstuds.php will finish executing?Please help

+1  A: 

You can include or require the file after execution.

Or, you can just do a good 'ol HTTP redirect: header( 'Location: regstuds.php' );. Only problem with doing a redirect is that if you already sent any headers back to the client, you cannot modify them after they have been already sent. But of course, there's a solution to that too: use JavaScript: window.location = "regstuds.php"; will do it.

Jacob Relkin
thanks, this is okay but I cant see the confirmation that I put in addstuds.php anymore:echo "<script>alert('Record successfully added!')</script>";
A: 

You could include the form handling code you have in addstuds.php at the top of regstuds.php and have the form action take you back to regstuds.php by using $_SERVER['PHP_SELF'].

As for the success message, you could set a flag if the add is successful and echo the script tag if that flag is true.

Walderman