Zend Controller fails to retrieve POST values from Zend Form in Chrome and Safari - forms

EDIT: Resolved itself. Recreated the LoginController and issue is gone. Thanks for the responses!
So I'm fairly new to Zend, so maybe I'm missing something blaringly simple. The scenario is pretty straightforward. I have a Zend_Form on index submit to /login, where I want to handle the username and password vars. I use a custom decorator to setup the form, and the resulting HTML looks like so:
<form id="loginForm" name="loginForm" enctype="application/x-www-form-urlencoded" method="post" action="/login">
<div class="input-container" id="username-container">
<input type="text" name="username" id="username" value="" helper="formText">
<div class="input-overlay">Username/Email</div>
</div>
<div class="input-container" id="password-container">
<input type="password" name="password" id="password" value="" helper="formPassword">
<div class="input-overlay">Password</div>
</div>
<div id="dropdown-checkbox-forgot-container">
<div class="checkbox-container" id="checkbox-container-rememberMe">
<input type="hidden" name="rememberMe" value="0">
<input type="checkbox" name="rememberMe" id="rememberMe" value="1" checked="checked" helper="formCheckbox" text="Remember me" class="light">
<div class="light checkbox-text" id="checkbox-text-rememberMe">Remember me</div>
</div>
Forgot password?
</div>
<input type="image" name="login" id="dropdown-login-submit" src="">
</form>
Great! Let's submit it! I put a simple var_dump in my LoginController to confirm that the values are transferred properly. var_dump($this->getRequest()->getPost()). FF and IE both show the values as they are supposed to be. However, Chrome and Safari do not show the username or password inputs. There is only a rememberMe value in the POST array. Strange...
Now I figure it might be Zend's accessing of the POST superglobal, so I change my code to var_dump($_POST). Same problem. In frustration I tried var_dumping both the $_POST and $this->getRequest()->getPost()....and it worked!? It dumped one copy with only the rememberMe input and one copy with everything (username and password included). No idea why or how that worked. Any insight as to what the problem might be would be greatly appreciated!

Recreated my LoginController through ZendTool and all worked as expected.

Related

Submit basic HTML form using Postman

I am trying to log into this website using Postman.
There is no username and this is what the HTML look like:
<body>
<div class="container">
<div class="loginbox">
<img id="logo" src="../gfx/logo.png" alt="" />
<form action="" method="POST">
Password: <input type="password" name="password" id="password" />
<button type="submit" name="submit" id="submit">Submit</button>
</form>
<p id="message">
</p>
</div>
</div>
</body>
This my POST request on Postman and I am not getting any "Wrong password." html back so I guess I am not doing the correct thing. How can I make a POST request to login using Postman?
The form includes two values, password and submit. The latter has no value associated with it, but the key is still being posted to the server.
It seems that the server-side code is using the submit key to trigger its logic. Just include that in your form data with no value.
Giving a "submit" key as empty in addition to the password field is needed . Please refer the sample request image given.

how to use a Hubspot form embed code with a bootstrap form

I have a client that uses hubspot for their tracking and thank you pages. I have created a landing page using bootstrap and within the page I have two forms. Both forms are the same and I want them to go to the same thank you page. The client has provided me with an embedd code but I am not sure how I can bridge the gap. Below I have listed my form code and the embed code. I basically want the user fields to be submitted into hubspot and for it to trigger the thank you page but I am not entirely sure this is possible. Any help would be appreciated.
<div class="col-lg-12 contact-form">
<div class="container">
<div class="formContainer">
<form role="form">
<div class="form-group">
<div class="col-sm-6 left-field">
<input type="text" class="bottom-form" id="firstname" placeholder="First Name">
</div>
<div class="col-sm-6 right-field">
<input type="text" class="bottom-form right-field" id="lastname" placeholder="Last Name">
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<input type="email" class="bottom-form email" id="email" placeholder="email">
</div>
<div class="col-sm-12">
<button type="submit" class="submit bottom-submit">Download Now</button>
</div>
</div>
</form>
</div>
</div>
</div>
Here is the hubspot embedd code.
<!--[if lte IE 8]>
hbspt.forms.create({
css: '',
portalId: '2030148',
formId: 'd9005302-a859-4a39-9d47-74d8a1d25fb0'
});
Are you just looking to set the redirect with the embed code? If so, here is the addition to the embed code:
portalId: 'xxxxxx',
redirectUrl: 'url goes here',
formId: 'd9005302-a859-4a39-9d47-74d8a1d25fb0'
I actually figured out a proper solution without having to do any redirects or hairy coding.
First I setup a local host, which was my biggest issue, this helps with getting the actual hubspot form to show within my page (using a local show the embedd code does not appear, although obvious to others, it took me a sec). Oh, I should mention that the code is not necessary.
Once you have it showing you basically inspect the element and then add to the classes that hubspot spits out get it to look that way you want too.

Can you tell me how to find out where form info goes?

Thank you for taking a look at my post. I have this newsletter form and it appears to be working fine, but I don't know where the information goes!
<form id="subscribe-form" name="sibscribe" method="post">
<label>
<input class="subscribetext" type="text" onFocus="if(this.value =='Enter E-mail:' ) this.value=''" onBlur="if(this.value=='') this.value='Enter E-mail:'" value="Enter E-mail:" name="keyword" />
</label>
<a onClick="document.getElementById('subscribe-form').submit()" class="button" href="Thank You.html">subscribe</a>
</form>
The best way to figure out for you is to go to Firebug Net bug while the page/form submits and inspect the tabs like:
Params| Headers|Responses|XML|Cookies

PHPSESSID appears in form arbitrarily

I have a login form written in PHP and each time I start the browser and go to the respective page, the first field of the form is this:
<input type="hidden" name="PHPSESSID" value="session_id_code" />
If I close the window, but I don't restart the browser, this doesn't happen. Any idea what's happening and why?
Thanks!
Form's code:
<?php
if (condition) {
?>
<form method="post" action="">
<dl>
<dt>Email:</dt>
<dd><input type="text" name="useremail" /></dd>
<dt>Password:</dt>
<dd>
<input type="password" name="userpass" /></dd>
<dt class="dt-buttons"><input type="submit" name="button_login" value="Login" class="button" /></dt>
</dl>
<input type="hidden" name="formkey" id="formkey" value="224ca00155w2fcda8906e1e40af03a71" />
</form>
<?php
}
?>
The form is simple HTML and is not dynamically generated.
EDIT2:
As I was saying, when I access the page for the first time after I started the browser, this thing happens. If I refresh the page afterwards, the hidden field doesn't show up.
Is it possible to have something to do with the SSL certificate? And if yes, why some pages/forms behave like this and some don't?
Sounds like you've got trans_sid enabled (transparent session id). Using trans_sid can be a security issue, especially if your site links to external content, or you allow link sharing - it lets a user's session ID leak out as part of the URL, meaning the session is highly vulnerable to hijacking.

Help required regarding Zend_Form

I wanted following output from Zend_Form please help
<form ...>
<div class="labels"><b>Name:</b></div>
<input type="text" value="" name="name" class="whitelabelform"><br>
<div class="labels"><b>Email:</b></div>
<input type="text" value="" name="email" class="whitelabelform"><br>
<div class="labels"><b>Security code:</b></div>
<div id="recaptcha_cs_fix">
<script type="text/javascript" src="http://src"></script></div>
<div id="submitbtn"><input type="image" alt="Submit Button" src="submit_button.png">
<input type="hidden" value="true" name="submitted"></div>
</form>
Watch this presentation, and you will manage to get any markup of Zend Form you need:
Leveraging Zend_Form Decorators
I won`t code it for you but I can point you to a tutorial about Zend_Form. Its very easy to create what you seek take a look at it.
After you have tried if it doesnt work ask again, posting your code and we will help you fix it.
You can have a form class which your elements are created there and call it in the php (zend view / .phtml file) using something like:
<?php echo $this->form->myformelement; ?>
provided that your controller also assigns the form created to the variable named "form".