how to popup on the same page not the post page?
Results 1 to 4 of 4

Thread: how to popup on the same page not the post page?

  1. #1
    Senior Member
    Join Date
    Oct 2011
    Posts
    267

    how to popup on the same page not the post page?

    Hi,

    I have a member.php page and within the member.php I have a <form> with;

    <form method="post" action="insert_member.php">

    In the insert.member.php I am checking if the user is exists in MySQL table.. If not, then I am INSERTING and then redirecting to another page but if exists I am displaying a popup dialog.

    when the popup is shown, it will be shown in a blank page and the address on the browser address bar is insert_member.php

    how can I let the popup message on the member.php?

  2. #2
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,405
    Quote Originally Posted by jrahma View Post
    In the insert.member.php I am checking if the user is exists in MySQL table.. If not, then I am INSERTING and then redirecting to another page but if exists I am displaying a popup dialog.
    Assuming you've got a well-defined schema (i.e. you have UNIQUE/PRIMARY constraints on the appropriate column(s)), note that the first check is superfluous. It would be more efficient (and less code) to simply execute the INSERT statement and check if it fails due to duplicate data.

    Regardless, this doesn't appear to be the source of your problem.

    Quote Originally Posted by jrahma View Post
    when the popup is shown, it will be shown in a blank page and the address on the browser address bar is insert_member.php
    Right, because when you submit a form, your browser makes a new request (a POST one, in this case) in order to display a completely new document/page.

    Quote Originally Posted by jrahma View Post
    how can I let the popup message on the member.php?
    Use AJAX (or something similar) to send a POST request to your server in the background without loading a new page; if it indicates an error, use Javascript to display the pop-up message. Otherwise, if it indicates a success, redirect the user to a new URL as appropriate.

  3. #3
    Senior Member
    Join Date
    Oct 2011
    Posts
    267
    Quote Originally Posted by bradgrafelman View Post
    Use AJAX (or something similar) to send a POST request to your server in the background without loading a new page; if it indicates an error, use Javascript to display the pop-up message. Otherwise, if it indicates a success, redirect the user to a new URL as appropriate.
    but using javascipt or ajax on php means when I check if record is exists then my connection and query code will be exposed to user? right? please advise..

  4. #4
    High Energy Magic Dept. NogDog's Avatar
    Join Date
    Aug 2006
    Location
    Ankh-Morpork
    Posts
    13,897
    No, the Javascript AJAX function will send a HTTP request to the web server just as a "normal" form submission would. The Javascript does not actually do any server-side processing (which will be done by the PHP script that the Javascript sends its request to). It then listens for the HTTP response back from the server, which it then uses to change the local display (if needed).
    Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be." ~ from Nation, by Terry Pratchett

    "But the main reason that any programmer learning any new language thinks the new language is SO much better than the old one is because he’s a better programmer now!" ~ http://www.oreillynet.com/ruby/blog/...ck_to_p_1.html


    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •