JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 23rd, 2012, 11:30 AM
maxers maxers is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 1 maxers User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 52 sec
Reputation Power: 0
Help with Ajax Forms

I'm using PHP and Ajax to implement some forms. I got the PHP part working but am having a hard time on the Ajax part.

I have a login form that checks for the user's email address.

Here's the PHP code to check if an email address exists in the db.

PHP Code:
//connect to db

//query db

 
if(mysql_num_rows($result) > 0) {
    
//echo "true";  //email exists in db redirect user to logged in page
    
header ("loggedin.html");
    exit ();
  } else {
    echo 
"false";   //email doesn't exist in db show user registration form
 



If email exists in db I redirect the user to the logged in page. If it doesn't exist I want them to fill out a registration form. But, I want to display the registration form in a jQuery lightbox.

1. Can I have both (login and registration forms) on the same page? I would set the registration form to display none then on submit if the email doesn't exist I would then call the jquery lightbox to open the registration form. Is this possible?

2. How do I pass that "email doesn't exist" to Ajax? I'm not sure how PHP/Ajax interact. This is where I'm stuck. Any help is appreciated.

Here's the JS:
Code:
$(document).ready(function(){
    $.ajax({
      type: "POST",
      url: "index.php", //  the page where both my login and registration form live?
      data: value,
      success: function()
      {
         // not sure what to do here
      }
  });
 });

Reply With Quote
  #2  
Old October 24th, 2012, 07:33 PM
web_loone08's Avatar
web_loone08 web_loone08 is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2008
Posts: 605 web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 16 h 3 m 14 sec
Reputation Power: 69
Here is the jQuery documentation for your jQuery function.

http://api.jquery.com/jQuery.ajax/

You should be able to send a variable back from your responseText (from your PHP page) to either display the login lightbox or the registration lightbox.

If you do not know what I am talking about, if your an AJAX novice; then you might want to read up on how AJAX works and familiarize yourself with some of the basic syntax.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > Help with Ajax Forms

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap