Help required regarding Zend_Form - zend-framework

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".

Related

How to send data in form secretly

I want send hidden data with form.
my code is:
` <form action="my address" method="post">
<div>
<label for="title">Post title:</label>
<input type="text" id="title" name="title" value="My excellent blog post" />
</div>
<div>
<label for="content">Post content:</label>
<textarea id="content" name="content" cols="60" rows="5">
This is the content of my excellent blog post. I hope you enjoy it!
</textarea>
</div>
<div>
<button type="submit">Update post</button>
</div>
<input type="hidden" name="seckey" value="34657" />
</form> `
I use hidden input, but is not safe.
I want to send "seckey" secretly in a way ,that is not available in any way and anybody not access it. Completely safe
but if I use hidden input, the "seckey" is visible in the source page or inspect element in browser.
How to post the "seckey" in the form without it even being clear in the page source

post form to an iframe on another form (is it possible)

I'm using ASP.NET web forms and i need to post data to an iframe, the problem is that in web forms I have the main form tag(form1), so i need another form tag(form2), to post data to the iframe that is in the main form1.
Basically i have this:
<form method="post" id="form2" action="http://localhost:58903/WebForm1.aspx" target="webApp">
<input type="hidden" name="ValidationUserName" value="david" />
<input type="hidden" name="ValidationTokenId" value="13123132132" />
<button type="submit">Send info to inner iframe</button>
</form>
<form id="form1" runat="server">
<iframe id="webApp" name="webApp" src="http://localhost:58903/WebForm1.aspx" style="width: 800px; height: 800px;"></iframe>
</form>
With this approach in open a new tab, if i put the iframe outside it works ok, but if i do this the layout is changed and i don't want this.
Is this possible?
If all the forms are in the same domain you should not work with iframes.
What exactly are you trying to get here? didn't realize completely
Done it, it was missing the "name" attribute in the <form> tags.

Submit button for my contact form is not submitting and redirecting

I'm working on my second website and throughout creating this one and my first the people here on StackOverflow have been an amazing help.
I can just browse and find almost anything I wan't to know.
99% of problems I've had, I fixed with answers I've read on here.
So first of thank you all so much!
This is the first time I'm posting something because I'm not able to find the specific answer for my code.
There are people one here with the same problems but when I look at their code I'm just lost.
I know html a fair bit by now. It's the php that I'm clueless about.
I'm not looking for something fancy, I'm just trying to create a simple contact form.
So here is my question and code, I hope some of you are able to help me.
I used an PHP code from a youtube tutorial and it's deadeasy (as said before: first time PHP) yet I can't get it to work. Although I'm doing everything the same as the man in the clip. He shows his is working so I'm extremely curious as to way mine is not?
My form does not 'send' and after clicking the submit button I don't get the 'thank you' line.
here is the html:
<form method="post" action="contactform" name="contactform" id="contactform">
<ol>
<li>
<label for="voornaam">Voornaam</label>
<input type="text" name="voornaam" />
</li>
<li>
<label for="achternaam">Achternaam</label>
<input type="text" name="achternaam" />
</li>
<li>
<label for="telefoon">Telefoon Nummer</label>
<input type="text" name="telefoon" />
</li>
<li>
<label for="email">E-mail Adres</label>
<input type="text" name="email" />
</li>
<li>
<label for="bericht">Type hier je bericht</label>
<textarea name="bericht"></textarea>
</li>
<li>
<input name="submit" type="submit" value="submit" />
<input name="reset" type="reset" value="reset" />
</li>
</ol>
</form>
and the PHP:
<?php
$voornaam = $_POST ['voornaam'];
$achternaam = $_POST ['achternaam'];
$telefoon = $_POST ['telefoon'];
$email = $_POST ['email'];
$bericht = $_POST ['bericht'];
$to = "felicevancuyk#gmail.com";
$subject = "dkl groep bericht";
mail ($to, $subject, $bericht, "From " . $voornaam . $achternaam . $telefoon};
echo "Bedankt. We nemen zo snel mogelijk contact met u op.";
?>
It could be that your action is not set correctly:
<form method="post" action="contactform" name="contactform" id="contactform">
This action tag is the URL that the form is sent to. In the above example you gave, it doesn't appear to be a file name. You want it to be something like this:
<form method="post" action="http://mysite.com/process-form.php" name="contactform" id="contactform">
Also note that in your example PHP code you are emailing responses to the form without cleaning those responses. Someone could send malicious code to your server if you don't clean the data first.
Something like:
$cleaned_voornaam = preg_replace("/[^ 0-9a-zA-Z]/", "_", $_POST['voornaam']);
Good luck!
You have to just change your action attribute of first line of code to the page where you want to process your form. It may be the same page but it is recommend to be on another page. Here is an example to submit the form in the same page:
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="contactform" id="contactform">
Don't forget if you are submitting on the same page as like the above example then your page should be in .php extension otherwise it will not work.
Another case for submit not submitting is that html is malformed.
Just happened that my code was inserting a php error in the middle of my html form.
fixed the error, the submit is working again.
In my case, no js involved at all

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

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

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.