Start working from a simple base. Add FormHelper to your application
then try the following:

    <?php
        echo $form->create('User');
        echo $form->input('username');
        echo $form->input('password');
        echo $form->end('Login');
    ?>

You will need to rework your jQuery so the IDs match the generated
HTML. Small steps at first, and once things are working you can
elaborate again.

On Jul 7, 6:50 pm, jeff <[email protected]> wrote:
> thanks for the reply
>
> i changed the namefield value to data[User][username] and
> data[User][password]
>
> but there isnt any result....
>
> should i completely rewrite the login view page using the helpers.......
>
> if so can u tell me how to include the values for id, name for each field
>
> ie for the (form,username,password and submit ) cuz i use this values in css
> and javascript
>
> calls.....
>
> thankz.........................................
>
>
>
> On Tue, Jul 7, 2009 at 1:55 PM, Robert P <[email protected]> wrote:
>
> > First, the obvious: build your forms using FormHelper. FormHelper will
> > help with form integration with CakePHP.
>
> > The main problem with your form is the naming of the fields. When
> > using Cake "username" just doesn't cut it, because the framework is
> > expecting a specific data structure. Try renaming your fields to
> > something like "data[User][username]" and "data[User][password]",
> > which is the format given to them by the helpers.
>
> > On Jul 7, 3:46 pm, jeremy <[email protected]> wrote:
> > > hai guys am new to this cakephp stuff and is having problem using
> > > cakephp with jquery...
>
> > > my problem is that am not able to get the values posted from jquery to
> > > a controller in php...
>
> > > my controller file is simple and is given below...
>
> > > users_controller.php
> > > ======================
>
> > > <?php
> > > class UsersController extends AppController
> > > {
> > >         var $name = "Users";
> > >         var $uses = null;           //if no DB connection is reuired……….
>
> > >         function index()
> > >         {
>
> > >         }
>
> > >         function login()
> > >         {
> > >                         print_r($this->params['form']);
> > >                         echo "<br/>";
> > >                         echo "<br/>";
> > >                         echo "<br/>";
> > >                         print_r($_REQUEST);
> > >                         echo "<br/>";
> > >                         echo "<br/>";
> > >                         echo "<br/>";
> > >                         print_r($_POST['username']);
> > >                         echo "<br/>";
> > >                         echo "<br/>";
> > >                         echo "<br/>";
> > >                         echo $_POST['data'];
> > >                         echo "<br/>";
> > >                         echo "<br/>";
> > >                         echo "<br/>";
> > >                         print_r($this->data);
> > >                         echo "<br/>";
> > >                         echo "<br/>";
> > >                         echo "<br/>";
>
> > >           }
>
> > > }
>
> > > ?>
> > > ===========================
>
> > > -> what am doing in this controller is just trying to output the value
> > > posted from jquery,But none
>
> > >     of them seems to work....
>
> > > ->my view files for login is given below
>
> > > login.ctp
> > > =================================
> > > <html>
> > > <head>
> > > <?=$html->css('general');?>
> > > <?=$javascript->link('jquery'); ?>
> > > <?=$javascript->link('jquery.form'); ?>
> > > <?=$javascript->link('LoginValidation'); ?>
> > > </head>
> > > <body>
> > > <h1 align="center"><u>Login Page</u></h1>
> > > <form method="post" action="" id="customForm" name="customForm">
> > > <table cellpadding="0" cellspacing="10">
> > > <tr><td>User Name :</td><td><input id="username" name="username"
> > > type="text" /></td><td><span id="usernameInfo"></span></td></tr>
> > > <tr><td>Password :</td><td><input id="password" name="password"
> > > type="password" /></td><td><span id="passwordInfo"></span>
> > > </td></tr>
> > > <tr><td colspan="2" align="right"><input id="submit" name="submit"
> > > type="submit" value="Log In" /></td></tr>
> > > </table>
> > > </form>
> > > </body>
> > > </html>
>
> > > =============================
>
> > > ->the login view is just a simple one which uses plain php coding...i
> > > havent used any helpers,
> > >    sorry for that.....but am comfortable using this....
>
> > > ->finally my javascript code LoginValidation.js where the view
> > > specific validation is given below
>
> > > LoginValidation.js
> > > ===================================
> > > // JavaScript Document
> > > $(document).ready(function(){
>
> > > //global vars
> > > var form = $("#customForm");
> > > var username = $("#username");
> > > var password = $("#password");
> > > var usernameInfo = $("#usernameInfo");
> > > var passwordInfo = $("#passwordInfo");
> > > var site_url = "http://localhost/jeffery/cake_jquery/";;
> > > //http://localhost/jeffery/cake_jquery/users/loginvar str = $
> > > ("form").serialize();
>
> > > //On blur
> > > username.blur(validateUserName);
> > > password.blur(validatePassword);
>
> > > //On key press
> > > username.keyup(validateUserName);
> > > password.keyup(validatePassword);
>
> > > //On Submitting
> > > form.submit(function(){
> > >         if(validateUserName()  &  validatePassword() )
> > >                 {
>
> > >                         $.ajax({
> > >                                         type: "POST",
> > >                                         url: "
> >http://localhost/jeffery/cake_jquery/users/login";,
> > >                                         data: "username="+ username.val()
> > + "password=" + password.val(),
> > >                                         success: function(){
> > >                                                 form.hide();
>
> > $('div.success').fadeIn();
> > >                                         }
> > >                                 });
> > >                                 return false;
> > >                 }
> > >                 return false;
>
> > > });
>
> > > //validation functions
> > > function validateUserName(){
> > >                 //if it's NOT valid
> > >                 if(username.val() == ""){
> > >                         username.addClass("error");
> > >                         usernameInfo.addClass("error");
> > >                         usernameInfo.text("User Name is required !!!");
> > >                         return false;
> > >                 }
> > >                 else
> > >                 {
> > >                         username.removeClass();
> > >                         usernameInfo.removeClass();
> > >                         usernameInfo.text("");
> > >                         return true;
> > >                 }
>
> > > }
>
> > > function validatePassword(){
>
> > >                 //it's NOT valid
> > >                 if(password.val() == ""){
> > >                         password.addClass("error");
> > >                         passwordInfo.addClass("error");
> > >                         passwordInfo.text("Password is required !!!");
> > >                         return false;
> > >                 }
> > >                 //it's valid
> > >                 else
> > >                 {
> > >                         password.removeClass();
> > >                         passwordInfo.removeClass();
> > >                         passwordInfo.text("");
> > >                         return true;
> > >                 }
> > >         }
>
> > > });             //      end of $(document).ready(function()
>
> > > ============================================
>
> > > => so what i intend to do here is use a login form, validate it and
> > > submit it via ajax, so that page is not refreshed......
>
> > > =>and am just trying to view the submiited data via ajax in the login
> > > controller just to make sure
>
> > >     that the controller is receiving the value.....
>
> > > => THE PROBLEM IS AM NOT GETTING THE VALUES TO BE VIEWD......
>
> > > => ANY HELP FROM U GUYS WILL BE VERY GREATFULLL
>
> > > =>THANKS IN ADVANCE..........................................
>
> --
> --
> (¨`•.•´¨) I may be busy,
> `•.¸(¨`•.•´¨)  but I assure you,
> (¨`•.•´¨)¸.•´ you are always in my heart
> `•.¸.•´
>
> With Lots of Love.....
>
> THANKS AND REGARDS
>
> Jeffery Jacob
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to