View Full Version : Handling forms with PHP
devbistro
03-27-2005, 07:48 PM
Hey guys,
Do you use any library (custom or public) to process your forms using PHP? If so, what is it and can you recommend it? If the library is designed around MVC programming pattern, it's even better...
Thanks a lot,
James
clasione
03-27-2005, 08:38 PM
What do you mean by library?Generally I just set something up in 1 .php file from an action command.
devbistro
03-27-2005, 09:29 PM
What do you mean by library?Generally I just set something up in 1 .php file from an action command.
that's what i do as well: i usually code my own 1-page form handler. this package (aka library) gives you a mini-framework to render forms and accept/validate user input. http://pear.php.net/package/HTML_QuickForm . i've never used it but just know it's there.
I favour using pre-existing open-source libraries as they are a product of several developers and a lot of testers (user community). also, i am coming from Java world where using libraries in general is the way to go
painperdu
04-05-2006, 02:09 PM
The libraries and frameworks are more standardized with Java than PHP. PEAR was well intentioned but there were existing libraries PHP developers were hooked on and PEAR still hasn't gained the momentum necessary to become universally accepted.
Even still, there are new PHP frameworks being developed that just fragments developer acceptance further. No one wants to get locked into a system that may or may not be here in the future, or of which development slows down, or a million other reasons so everyone develops their own libraries and the problem just grows.
Instead of learning a new framework and taking the chances mentioned above I've developed my own function libraries.
Websmarts
04-05-2006, 03:15 PM
Here is an email php form
Form below looks like this
http://www.sundaybrew.com/contact.php
/////////////form below////////////////////////
<?
//your sitename
$sitename="yoursitename";
//your email
$tomail = "you@domain.com";
$name=$_POST[name];
$email2=$_POST[email2];
$amsg=$_POST[questions];
if($name && $email2){
$subject = "$sitename -- Contact Page";
$headers = "From: $_POST[name] <$email2>\r\nReply-To: $replyto\r\n";
$headers .= "X-Sender: <$email2>\n";
$headers .= "X-Mailer: PHP\n"; // mailer
$headers .= "Return-Path: info@youremail/n"; // Return path for errors
$headers .= "Content-type: text/html\n\n";
mail($tomail,$subject,$amsg, $headers);
echo("Thank you, your message was successfully sent.");
}
?>
<table style="margin-top:10px;" cellspacing="10" width="100%">
<tr>
<td valign="top" id="st"> <div align="left" style="padding-left:10px;background-color:#872729;color:#ffffff;font-size:16px;">
<b>Contact Us</b> </div>
<br> <form action="contact.php" method="POST">
<b>Name</b><br>
<input type=text name=name size=30 tabindex="1">
<br>
<span style="padding-left:5px;"><br>
<b>Email</b><br>
</span>
<input type=input name=email2 size=30 tabindex="2">
<br>
<span style="padding-left:5px;"><br>
<b>Questions/Comments</b><br>
<textarea name="questions" cols="39" rows="4" tabindex="3"></textarea>
<br>
</span> <br>
<input type="hidden" name="subject" value="subject in subject line">
<input type="submit" name="" value="Send!">
<br>
</form></p>
</td>
</tr>
</table>
<?
?>
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.