Note that there are some explanatory texts on larger screens.

plurals
  1. POValidation in Two Form On Same Page In CakePHP
    primarykey
    data
    text
    <p>I am learner in CakePhp. I am developing a login and signup functionality on single page.I am using same Model named 'User' for it.But On validating the both form,When I submit Signup Form same error message shown in both signup and login form. Here is the code</p> <p><strong>UsersController</strong></p> <pre><code>class UsersController extends AppController { public $layout = 'test'; public $components = array('Security'); public function index(){ if($this-&gt;request-&gt;is('Post')){ if($this-&gt;request-&gt;data['User']['email']){ $this-&gt;User-&gt;set('creation_date',date('Y-m-d H:i:s')); $this-&gt;request-&gt;data['User']['password'] = Security::hash($this-&gt;request-&gt;data['User']['password'], 'md5', true); if($this-&gt;User-&gt;save($this-&gt;request-&gt;data)){ //$this-&gt;Session-&gt;setFlash('Your data is Entered'); $this-&gt;Session-&gt;write('username', $this-&gt;request-&gt;data['User']['user_name']); $this-&gt;flash('You are signed Up', 'dashboard'); //$this-&gt;redirect(array('action'=&gt;'dashboard')); } else{ $this-&gt;Session-&gt;setFlash('Data is Not Save'); } } else { $username = $this-&gt;request-&gt;data['User']['user_name']; $password = Security::hash($this-&gt;request-&gt;data['User']['password'], 'md5', true); $query = $this-&gt;User-&gt;find('all',array('conditions'=&gt;array('User.user_name'=&gt;$username, 'User.password'=&gt;$password))); if (sizeof($query)!=0){ $this-&gt;Session-&gt;write('username', $query[0]['User']['user_name']); $this-&gt;redirect('dashboard'); } else { $this-&gt;Session-&gt;setFlash("User is Not Valid"); } } } } } </code></pre> <p><strong>index View</strong></p> <pre><code> &lt;div id="loginForm"&gt; &lt;?php echo $this-&gt;form -&gt; create('', array('url'=&gt;array('controller'=&gt;'Users','action'=&gt;'index')));?&gt; &lt;table cellpadding="10"&gt; &lt;?php echo '&lt;tr&gt;&lt;td&gt;'.$this-&gt;form -&gt; input('user_name', array('placeholder'=&gt;'UserName')).'&lt;/td&gt;'; echo '&lt;td&gt;'.$this-&gt;form -&gt; input('password', array('id'=&gt;'password','placeholder'=&gt;'Password')).'&lt;/td&gt;'; echo '&lt;td&gt;'.$this-&gt;form -&gt; end('Login').'&lt;/td&gt;&lt;/tr&gt;'; ?&gt; &lt;/table&gt; &lt;/div&gt; &lt;center&gt; &lt;h1&gt;Create Account&lt;/h1&gt; &lt;div id="signupForm"&gt; &lt;table cellpadding="5"&gt; &lt;?php echo $this-&gt;form -&gt; create('', array('url'=&gt;array('controller'=&gt;'Users','action'=&gt;'index'),'inputDefaults'=&gt;array('label'=&gt;FALSE)));?&gt; &lt;tr&gt; &lt;td&gt;User Name:- &lt;?php echo $this-&gt;form -&gt; input('user_name', array('placeholder'=&gt;'UserName'));?&gt;&lt;/td&gt; &lt;td&gt; Email:- &lt;?php echo $this-&gt;form -&gt; input('email', array('placeholder'=&gt;'Email'));?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Mobile No:- &lt;?php echo $this-&gt;form -&gt; input('mobile_no', array('placeholder'=&gt;'Mobile')).'&lt;br&gt;';?&gt;&lt;/td&gt; &lt;td&gt;Password:- &lt;?php echo $this-&gt;form -&gt; input('password', array('placeholder'=&gt;'password')).'&lt;br&gt;';?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;&lt;td colspan="2"&gt;&lt;center&gt;&lt;?php echo $this-&gt;form -&gt; end('Sign Up');?&gt;&lt;/center&gt;&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; </code></pre> <p></p> <p><strong>Here is Scren Shot</strong><img src="https://i.stack.imgur.com/1KBrb.png" alt="enter image description here"> I have searched a lot but i cant get any useful solution.Please tell what should i do.</p> <p>Thank You. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload