Hi
I'm still new to this but I think I'm making progress. Below is a functioning script that inserts 4 fields into a database. After advice from a previous post the form is being processed on the same page. The insert into database works fine but I only want to display the 'thank you message' after data has been entered. Currently it is displayed all the time.
Here's the script:
[PHP]// connect to server & open database
include '../include/config.php';
include '../include/opendb.php';
$Name = $_POST['Name'];
$ADno = $_POST['ADno'];
$RecFriend = $_POST['RecFriend'];
$RecEmail = $_POST['RecEmail'];
// add info into the database
mysql_query($qu ery);
$query="INSERT INTO recommended (Name, ADno, RecFriend, RecEmail) VALUES ('$Name','$ADno ','$RecFriend', '$RecEmail')";
if(!mysql_query ($query)) die(mysql_error ());
echo "Thank you for your recommendation! ";
//close db
include '../include/closedb.php';
[/PHP]
Can someone give me an idea where to go from here and confirm (hopefully) that what I have done so far is solid.
Thanks people.
I'm still new to this but I think I'm making progress. Below is a functioning script that inserts 4 fields into a database. After advice from a previous post the form is being processed on the same page. The insert into database works fine but I only want to display the 'thank you message' after data has been entered. Currently it is displayed all the time.
Here's the script:
[PHP]// connect to server & open database
include '../include/config.php';
include '../include/opendb.php';
$Name = $_POST['Name'];
$ADno = $_POST['ADno'];
$RecFriend = $_POST['RecFriend'];
$RecEmail = $_POST['RecEmail'];
// add info into the database
mysql_query($qu ery);
$query="INSERT INTO recommended (Name, ADno, RecFriend, RecEmail) VALUES ('$Name','$ADno ','$RecFriend', '$RecEmail')";
if(!mysql_query ($query)) die(mysql_error ());
echo "Thank you for your recommendation! ";
//close db
include '../include/closedb.php';
[/PHP]
Can someone give me an idea where to go from here and confirm (hopefully) that what I have done so far is solid.
Thanks people.
Comment