Per delle prove un file di testo va bene, poi è inutile dire che in ambito web si rende assolutamente necessario un database per la massiccia, o meno, archiviazione dati.
Per quanto riguarda la tua richiesta, penso che potresti fare così:
File PHP:
codice:
<?php
session_start();
$con = mysql_connect("localhost","root","root") or die("Errore connessione MySQL");
mysql_select_db("school", $con) or die("Errore connessione database");
MySQL_query("INSERT INTO student (id, name, class) VALUES ('".$_POST["id"]."','".$_POST["name"]."','".$_POST["class"]."')") or die("Errore invio query string");
mysql_close($con);
$_SESSION["mex"]="Benvenuto ".$_POST["name"].", grazie per esserti loggato!";
echo "<HTML><HEAD><SCRIPT TYPE='TEXT/JAVASCRIPT'>location.href='index.php';</SCRIPT></HEAD><BODY></BODY></HTML>";
?>
Trasformi il file Recordinsertform.html in Recordinsertform.php e poi:
codice:
<?php session_start(); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Form Input Data</title>
</head>
<body onload="javascript:<?php if($_SESSION["mex"]){ echo "alert('".$_SESSION["mex"]."');\">"; unset($_SESSION["mex"]);} else echo "\">"; ?>
<table border="1">
<tr>
<td align="center">Form Input Employees Data</td>
</tr>
<tr>
<td>
<table>
<form method="post" action="Recordinsert.php">
<tr>
<td>ID</td>
<td><input type="text" name="id" size="5">
</td>
</tr>
<tr>
<td>NAME</td>
<td><input type="text" name="name" size="40">
</td>
</tr>
<tr>
<td>CLASS</td>
<td><input type="text" name="class" size="5">
</td>
</tr>
<tr>
<td></td>
<td align="right"><input type="submit"
name="submit" value="Sent"></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
Naturalmente puoi sfruttare il fatto che hai già la sessione aperta nella pagina "padre" (in questo caso Recordinsertform) senza aprirla unicamente per il messaggio di benvenuto. Nel caso, invece, non ti interessa rimanere aperta la sessione, la puoi semplicemente distruggere:
codice:
<body onload="javascript:<?php if($_SESSION["mex"]){ echo "alert('".$_SESSION["mex"]."');\">"; unset($_SESSION["mex"]); session_destroy();} else echo "\">"; ?>