View Full Version : php forms
jlknauff
07-19-2004, 10:54 AM
can someone point me to a php script that is easy to modify? I want to replace my cgi with php but I don't know much about it.
Pyrrhonist
07-20-2004, 12:54 AM
What kind of php script are you looking for?
try hotscripts.com, they tend to have lots of good php scripts (and any language for that matter) to play with.
If you're trying to do a common task like contact forms, or databse connections, check out some online tutorials. When I was learning, i used the resources at codewalkers quite a bit until I knew what I was doing.
jlknauff
07-20-2004, 08:59 AM
Actually I just found a php thing that I installed on my webserver and you plug in your form info and it creates the form and the script-perfectly configured. The only thing that I haven't been able to do is figure out how to change the from and subject line of the email that it sends when they submit the form.
Anyway, if anyone else wants it here it is http://phpformgen.sourceforge.net/
Pyrrhonist
07-20-2004, 09:09 AM
at the end of the php script, there should be a function something like (I don't have it in front of me, so my syntax might be wrong)
mail("to_goes_here", "subject_goes_here", "message_content_here", "From: from_email"):
There are options for a couple other additional headers, and they would go either before or after the From: option.
I usually load my messages as they're created, so take a look at the mail message, and you should be able to backwards engineer from there.
jlknauff
07-21-2004, 12:33 PM
I got everything to work exactly the way that I want it with one exception. In the from line it tags a "io.hyperdrivedns.net" at the end of the name. I'll post the php file and see if anyone can tell me if it's in there or else where. Here it is:
<?php
include("global.inc.php");
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
pt_register('POST','Name');
pt_register('POST','Company');
pt_register('POST','Phonenumber');
pt_register('POST','Email');
pt_register('POST','Address');
pt_register('POST','State');
pt_register('POST','Zip');
pt_register('POST','Contacttime');
pt_register('POST','Comments');
$Comments=preg_replace("/(\015\012)|(\015)|(\012)/"," <br />", $Comments);if($Name=="" || $Company=="" || $Phonenumber=="" || $Email=="" || $Contacttime=="" ){
$errors=1;
$error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
}
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$Email)){
$error.="<li>Invalid email address entered";
$errors=1;
}
if($errors==1) echo $error;
else{
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="Name: ".$Name."
Company: ".$Company."
Phone number: ".$Phonenumber."
Email: ".$Email."
Address: ".$Address."
State: ".$State."
Zip: ".$Zip."
Contact time: ".$Contacttime."
Comments: ".$Comments."
";
$message = stripslashes($message);
mail("retailerinfo@jeremy-lang.com","Retailer info request",$message,"From: $Company");
header("Refresh: 0;url=http://www.jeremy-lang.com/thankyou.htm");
?><?php
}
?>
:confused: there is also another file that this php seems to load so I'll post that too
<?php
function pt_register()
{
$num_args = func_num_args();
$vars = array();
if ($num_args >= 2) {
$method = strtoupper(func_get_arg(0));
if (($method != 'SESSION') && ($method != 'GET') && ($method != 'POST') && ($method != 'SERVER') && ($method != 'COOKIE') && ($method != 'ENV')) {
die('The first argument of pt_register must be one of the following: GET, POST, SESSION, SERVER, COOKIE, or ENV');
}
$varname = "HTTP_{$method}_VARS";
global ${$varname};
for ($i = 1; $i < $num_args; $i++) {
$parameter = func_get_arg($i);
if (isset(${$varname}[$parameter])) {
global $$parameter;
$$parameter = ${$varname}[$parameter];
}
}
} else {
die('You must specify at least two arguments');
}
}
?>
I don't see anything related in either of these but I don't know anything about php so maybe I am missing something simple. Thanks in advance.
Just wanted to recommend you http://easyformit.com. Check it, hope you
find featured needed. I think, great tool for your webforms.
vBulletin v3.0.3, Copyright ©2000-2013, Jelsoft Enterprises Ltd.