Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8823041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:15:20+00:00 2026-06-14T06:15:20+00:00

I have a registration form in html and a php code that connects to

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:15:21+00:00Added an answer on June 14, 2026 at 6:15 am

    Try this, it should work

    if(success)
    {
       echo "<script type=\"text/javascript\">".
            "alert('success');".
            "</script>";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an HTML form that submits to a PHP file for MySQL insertion
I am trying to create a simple registration form. I have the following: include('User.datatype.php');
I am trying to create simple user registration form. I have an index.html file
In my web application i have registration form, when user register i want to
I have a registration form where this CSS rules apply. when user submits with
I have a user registration form. I am doing server side validation on the
my issue is that i have two ajax calls to php for a registration
I have a script below which the user logs a php form. There is
I have registration form and I am using Django-registration. Now, I need to add
I have the following form with Formtastic: = semantic_form_for @user, :url=> url_for(register_path), :html =>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.