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

  • SEARCH
  • Home
  • 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 9105263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:03:51+00:00 2026-06-17T02:03:51+00:00

I have created an html form for registering and when a user has successfully

  • 0

I have created an html form for registering and when a user has successfully registered I want them to be automatically redirected back to my index.html page and for an alert to pop up tell them they have Registered Successfully. Currently my alert works but it just opens up in a blank page. I have tried putting in header ("location:../index.html") but that has not worked, it just directs me straight to the page without giving me the alert i want. Can anyone help with this?

<?php
$con = mysql_connect("localhost","root","") or die(mysql_error());
$select_db = mysql_select_db("mayan",$con);
if(isset($_POST['register']))
{
     $firstname=$_POST['first_name'];
     $lastname=$_POST['last_name'];
     $address=$_POST['address'];
     $postcode=$_POST['postcode'];
     $emailaddress=$_POST['emailaddress'];
     $password=$_POST['password'];
     $query = "select emailaddress FROM mayan_users where emailaddress='$emailaddress'";
     $link = mysql_query($query)or die(mysql_error());
     $num = mysql_num_rows($link);
 if ($num>0){
  echo 'Email already exists'; //email already taken
 }

 else {
 $insert_query = "insert into `mayan_users`(`firstname`,`lastname`,`address`,`postcode`,`emailaddress`,`password`) values('$firstname','$lastname','$address','$postcode','$emailaddress','$password')";
 $result = mysql_query($insert_query)or die(mysql_error());



  if(success)
{
   echo "<script type=\"text/javascript\">".
        "alert('success');".
        "</script>";
}
     }

   }
?>
  • 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-17T02:03:52+00:00Added an answer on June 17, 2026 at 2:03 am

    Use this function when redirecting:

    function redirect($url) {
        if(!headers_sent()) {
            //If headers not sent yet... then do php redirect
            header('Location: '.$url);
            exit;
        } else {
            //If headers are sent... do javascript redirect... if javascript disabled, do html redirect.
            echo '<script type="text/javascript">';
            echo 'window.location.href="'.$url.'";';
            echo '</script>';
            echo '<noscript>';
            echo '<meta http-equiv="refresh" content="0;url='.$url.'" />';
            echo '</noscript>';
            exit;
        }
    }
    

    So you want to redirect to the same page but with a ?=XXX Get value

    Your code would look something like this:

    <?php
    
    if ($_GET['success'] == 1){
            echo "<script type=\"text/javascript\">".
            "alert('success');".
            "</script>";
    }
    $con = mysql_connect("localhost","root","") or die(mysql_error());
    $select_db = mysql_select_db("mayan",$con);
    if(isset($_POST['register']))
    {
         $firstname=$_POST['first_name'];
         $lastname=$_POST['last_name'];
         $address=$_POST['address'];
         $postcode=$_POST['postcode'];
         $emailaddress=$_POST['emailaddress'];
         $password=$_POST['password'];
         $query = "select emailaddress FROM mayan_users where emailaddress='$emailaddress'";
         $link = mysql_query($query)or die(mysql_error());
         $num = mysql_num_rows($link);
     if ($num>0){
      echo 'Email already exists'; //email already taken
     }
    
     else {
     $insert_query = "insert into `mayan_users`(`firstname`,`lastname`,`address`,`postcode`,`emailaddress`,`password`) values('$firstname','$lastname','$address','$postcode','$emailaddress','$password')";
     $result = mysql_query($insert_query)or die(mysql_error());
    
    
    
      if(success)
    {
       redirect('index.php?sucess=1');
    }
         }
    
       }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have successfully created an HTML form that gets a file from a user
When you have an ASP.Net MVC form created by Html.BeginForm(), how do fields inside
i have create a form (so it's PHP and HTML hybrid-code). it has ability
I have created a HTML form and im trying to link it to a
I have created one html form with following fields: Name (Text Box) Email (Text
I have created an HTML form with a search box and a drop down
I have created an html form. it consist of several drop down list for
I have created a from with the code below: HTML: <form> <div class=searchInputBox> <input
hey i am working on form using the tutorial http://symfony.com/doc/current/book/forms.html I have created a
I have created a form in the user's browser with JavaScript. Later on I

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.