I have a registration form in html and a php code that connects to the database. Now if the registration is successful and is added to the database, how to i alert the user that it is successful with a popup box?
the html code is just a simple form codes so heres the php code:
<?php
if(isset($_POST['submit'])){
$fname = $_POST['firstname'];
$lname = $_POST['lastname'];
$mname = $_POST['middlename'];
$birthday = $_POST['year'] . '/' . $_POST['month'] . '/' . $_POST['day'];
$sex = $_POST['sex'];
$age = $_POST['age'];
$address = $_POST['address'];
$telephone = $_POST['telephone'];
$occupation = $_POST['occupation'];
$telephone = $_POST['telephone'];
$cfname = $_POST['contactfirstname'];
$clname = $_POST['contactlastname'];
mysql_connect('localhost', 'root', '');
mysql_select_db('HMIS');
$query = "INSERT INTO `patientrecords` VALUES('','$lname','$fname','$mname','$birthday','$sex','$address','$telephone','$occupation','$clname','$cfname')";
if(mysql_query($query)){
echo "Registered";
}else{
echo "Error!". mysql_error();
}
}
?>
I can do the javascript alert box only when a certain button is clicked. But in the php code you dont need a button.. so.. how do you do it?
Try this, it should work