I want to insert my form data into database using cakephp. I created form.ctp file in layouts folder. Now how can I insert form values to database in form.ctp file?
Here is my code:
<html>
<form action="../users/register" method="post">
<p>Please fill out the form below to register an account.</p>
<label>Username:</label><input name="username" size="40" />
<label>Password:</label><input type="password" name="password" size="40"
/>
<label>Email Address:</label><input name="email" size="40"
maxlength="255" />
<label>First Name:</label><input name="first_name" size="40" />
<label>Last Name:</label><input name="last_name" size="40" />
<input type="submit" value="register" />
</form>
</html>
<html>
<form action="../users/register" method="post">
<p>Please fill out the form below to register an account.</p>
<label>Username:</label><input name="users[username]" size="40" />
<label>Password:</label><input type="users[password]" name="password" size="40" />
<label>Email Address:</label><input name="users[email]" size="40"
maxlength="255" />
<label>First Name:</label><input name="users[first_name]" size="40" />
<label>Last Name:</label><input name="users[last_name]" size="40" />
<input type="submit" value="register" />
</form>
</html>
and save by
if ($this->request->is('post')) {
$this->User->save($this->request->data);
}
OR
save your data without change form by
if ($this->request->is('post')) {
$this->request->data['User'] = $this->request->data;
$this->User->save($this->request->data);
}
Related
I have a react app that has a couple of inputs. The problem is, whenever I navigate to the page, it auto-fills all the fields with previously entered data on Microsoft Edge (The new one). I use Materialize for my styling. I implement my form like so:
<form onSubmit={this.handleSubmit} autoComplete='off' className="login-form">
<div className="input-field">
<input
placeholder='Type email here'
id="email"
type="email"
required
className="validate contact-input"
onChange={this.handleChange}/>
<label
className="active"
htmlFor="email">Email</label>
</div>
<div className="input-field">
<input
placeholder='Type password here'
id="password"
type="password"
required
className="validate contact-input"
onChange={this.handleChange}/>
<label
className="active"
htmlFor="password">Password</label>
</div>
<div className="input-field col s6">
<button className="btn z-depth-2 login-btn">
Sign In
</button>
</div>
</form>
Some solutions I have tried that do not work include:
<form autoComplete="off">
...
</form>
<form autoComplete="new-password">
...
</form>
<input autoComplete="off" />
<input autoComplete="new-password" />
<input autoComplete="none" />
Anyone know how to fix this?
Try this :
<input type="text" autocomplete="off" list="autocompleteOff"
id="fieldId" name="fieldname" placeholder="Placeholder here" />
Answer from here : Disable input text suggestions in Edge?
Hello I am trying to integrate PayFast to my ReactJS project but I am getting this error
signature : Generated signature does not match submitted signature
I do not understand because based on the docs https://developers.payfast.co.za/docs#step_2_signature we are to generate an Md5 hash then submit it through with the entire form
can I please get some assistance in resolving this I am using the default sandbox merchant_id and merchant_key
Code to PayFast Custom Form integration
<form action="https://sandbox.payfast.co.za/eng/process">
<input
type="hidden"
name="merchant_id"
value={process.env.REACT_APP_MERCHANT_ID}
/>
<input
type="hidden"
name="merchant_key"
value={process.env.REACT_APP_MERCHANT_KEY}
/>
<input
type="hidden"
name="return_url"
value="http://127.0.0.1:3000/success"
/>
<input
type="hidden"
name="cancel_url"
value="http://127.0.0.1:3000/cart/cancel"
/>
<input type="hidden" name="name_first" value="Junior" />
<input type="hidden" name="name_last" value="Hlongwane" />
<input
type="hidden"
name="email_address"
value="jh0417783#gmail.com"
/>
<input type="hidden" name="cell_number" value=<entered my number> />
<input type="hidden" name="amount" value="800.00" />
<input type="hidden" name="item_name" value="Test Item" />
<input type="hidden" name="email_confirmation" value="1" />
<input
type="hidden"
name="signature"
value="f103e22c0418655fb03991538c51bfd5"
/>
<button className="Cart__checkOutButton">
PROCEED TO CHECKOUT
</button>
</form>
I'm creating a signup model form with a react-responsive-modal library. I wrote my Modal like this
<Modal open={this.state.openCreateAlbum} onClose={this.onCloseModalCreate}>
<div className="modal-body">
<h2>Get Started Absolutely<span> Free!</span></h2>
<span className="subtitle">No credit card needed</span>
<form className="contact-form form-validate3" novalidate="novalidate">
<div className="form-group">
<input type="text" name="name" id="name" placeholder="First Name" required="" autocomplete="off" aria-required="true" />
</div>
<div className="form-group">
<input className="form-control" type="email" name="email" placeholder="E-mail" required="" autocomplete="off" aria-required="true" />
</div>
<div className="form-group">
<input type="password" name="pass" className="form-control" placeholder="Password" required="" autocomplete="off" aria-required="true" />
</div>
<input className="btn btn-md btn-primary btn-center" id="sign_up" type="button" value="Sign Up" />
</form>
</div>
</Modal>
Notice that for First Name field I'm not using className=form-control and for other fields, I'm using that className.
The problem I got is when I run that. I cannot enter text to email and password field but it's fine with the first name field. I don't know why and how to fix that. I followed a tutor video and he didn't have that issue. Here is the link to the video https://www.youtube.com/watch?v=YLQXEHDXnlU
Ps: Im using this library for Modal component https://www.npmjs.com/package/react-responsive-modal
Hi anybody know how to post reactjs form data to external URL like this.
<form id="fc_checkout" action="https://checkout.freecharge.in/api/v1/co/oauth/wallet/add" method="POST">
<input type="hidden" name="callbackUrl" value='somevalue' />
<input type="hidden" name="merchantId" value='somevalue' />
<input type="hidden" name="checksum" value='somevalue' />
<input type="hidden" name="amount" value='somevalue' />
<input type="hidden" name="loginToken" value='somevalue' />
<input type="hidden" name="channel" value='somevalue' />
<input type="hidden" name="metadata" value='somevalue' />
</form>
Thanks in advance.
I'm trying to update a database from a form without using any php, I'm using angularjs with MySql
If I use the following with the put method I can insert a user into the data base, I've
http://localhost:8080/CyberSolution/rest/user/register?u=tester&pw=fred&fname=Fred&lname=Smith&email=fred#localhost.com
I've made a basic html form
<form method="POST" action="">
Username: <input type="text" name="username" size="15" /><br />
Password: <input type="password" name="password" size="15" /><br />
email: <input type="text" name="email" size="15" /><br />
First name: <input type="text" name="first_name" size="15" /><br />
Last name: <input type="text" name="lirst_name" size="15" /><br />
<p><input type='submit' name='Submit' value='Submit' /></p>
</form>
I'm working with AJS for the first time and also REST for the first time, I'm unsure on how to link the form to the database to update. I'm unsure what needs to go in the controllers.js as well
Thanks
You could simply use the $http service.
First use ng-model to store fields value in an object :
<form ng-submit="send_form()" action="">
Username: <input type="text" name="username" size="15" ng-model="form.username" /><br />
Password: <input type="password" name="password" size="15" ng-model="form.password"/><br />
email: <input type="text" name="email" size="15" ng-model="form.email"/><br />
First name: <input type="text" name="first_name" size="15" ng-model="form.first_name"/><br />
Last name: <input type="text" name="lirst_name" size="15" ng-model="form.last_name"/><br />
<p><input type='submit' name='Submit' value='Submit' /></p>
</form>
And then use in your controller (or even better, through a service) :
function myController($scope, $http) {
$scope.send_form = function () {
$http.put('http://localhost:8080/CyberSolution/rest/user/register', $scope.form).success(successCallback);
}
}