PDA

View Full Version : form script



Mole
November 13th, 2006, 18:41
I need a form script where someone fills it out it submit the info to my email. I tried making one but it always opens the email thing up on the computer to submit.

I need the following lines


Full Name:
eMail Address:
Location:
(sub)Domain:
Plan:
Site Description :
Have you read the rules :


can someone make me 1?

Abush
November 13th, 2006, 23:32
hotscripts.com search for "form to email" GL

brutetal
November 14th, 2006, 00:25
There's a free cgi program, it comes with cpanel.
Its called FormMail.
Here's a link to the online documentation of the script, http://www.scriptarchive.com/readme/formmail.html

krakjoe
November 14th, 2006, 03:15
<?php
// Edit these parts
// "whm_name" => "friendly name"
$plans = array(
"user_plan" => "Plan 1",
"user_plan2" => "Plan 2"
);
// System email address, destination email
$sysmail = "KRAK_JOE@hotmail.com";
// From email address
$from = "system@host.com";
////////////////////////////////////////////////////////////////////////////////
// NO EDITING NO EDITING NO EDITING NO EDITING NO EDITING NO EDITING NO EDITING
////////////////////////////////////////////////////////////////////////////////


// The form for collection of data
$theForm = "
<center>
<fieldset>
<legend>Request an account</legend>
{ERROR}<br>
<form action=\"\" method=\"post\">
<label>First Name</label><br>
<input type=\"text\" name=\"first\"><br>
<label>Last Name</label><br>
<input type=\"text\" name=\"last\"><br>
<label>Email Address</label><br>
<input type=\"text\" name=\"email\"><br>
<label>Location</label><br>
<input type=\"text\" name=\"loc\"><br>
<label>sub(Domain)</label><br>
<input type=\"text\" name=\"dom\"><br>
<label>Plan</label><br>
<select name=\"plan\">
" . plans() . "
</select><br>
<label>Site Description</label><br>
<textarea name=\"desc\" rows=\"15\" cols=\"40\"></textarea><br>
<label>Have you read the TOS ?</label><br>
<select name=\"tos\"><option>Yes</option><option>No</option></select><br><br>
<input type=\"submit\" value=\"Request\">
</form>
</fieldset>
</center >
";
// Email subject
$subject = $_SERVER['REMOTE_ADDR'] . " : " . $_POST['first'] . " " . $_POST['last'];
// Email message
$message = "
You have recieved a request from :<br>
".$_POST['first']." ". $_POST['last'] ." @ " . $_SERVER['REMOTE_ADDR'] . "<br>
Details : <br>
<b>Email</b> " . $_POST['email'] . " <br>
<b>Location</b> " . $_POST['loc'] . " <br>
<b>Domain</b> " . $_POST['dom'] . " <br>
<b>Plan</b> " . $_POST['plan'] . " <br>
<b>Description</b> " . $_POST['desc'] . " <br>
";
// Start
if (!$_POST)
{
echo preg_replace("/{ERROR}/si", $error, $theForm);
exit;
}
elseif ($_POST['tos'] != "Yes")
{
$error = "<center><b>You MUST accept the TOS</b></center><br>";
echo preg_replace("/{ERROR}/si", $error, $theForm);
exit;
}
elseif (!preg_match("/.*?@.*?\..*?/si", $_POST['email']))
{
$error = "<center><b>Invalid Email address</b></center>";
echo preg_replace("/{ERROR}/si", $error, $theForm);
exit;
}
elseif (!preg_match("/.*?\..*?/", $_POST['dom']))
{
$error = "<center><b>Invalid domain name</b></center><br>";
echo preg_replace("/{ERROR}/si", $error, $theForm);
exit;
}
elseif ($_POST['desc'] == "")
{
$error = "<center><b>Description required</b></center><br>";
echo preg_replace("/{ERROR}/si", $error, $theForm);
exit;
}
elseif ($_POST['first'] == "" || $_POST['last'] == "")
{
$error = "<center><b>First AND last name required</b></center><br>";
echo preg_replace("/{ERROR}/si", $error, $theForm);
exit;
}
elseif ($_POST['loc'] == "")
{
$error = "<center><b></b></center><br>";
echo preg_replace("/{ERROR}/si", $error, $theForm);
exit;
}
elseif (@mail($sysmail, $subject, $message, "From: $from\nContent-Type: text/html; charset=iso-8859-1"))
{
$error = "<center><b>Request Sent</b></center>";
echo preg_replace("/{ERROR}/si", $error, $theForm);
exit;
}
else {
$error = "<center><b>An error occured sending email, plese contact support directly :</b><br>".
"$sysmail </center>";
echo preg_replace("/{ERROR}/si", $error, $theForm);
exit;
}
function plans()
{
global $plans;
foreach ($plans as $value)
{
$return .= "<option>$value</option>";
}
return $return;
}
?>


Edit the bits at the top to reflect the packages you wanna use, read the syntax carefully, have fun....

Decker
November 14th, 2006, 03:46
There's a free cgi program, it comes with cpanel.
Its called FormMail.
Here's a link to the online documentation of the script, http://www.scriptarchive.com/readme/formmail.html

Use one of the thousands of available free php scripts for that, formmail is notorious for spam/security issues.

As KJ says, hotscripts.com is probably the best place for it, pick scripts, php, email if your clicking through the sections, almost all have simple instructions and a form template included you can just modify simply to suit what you need.

krakjoe
November 14th, 2006, 04:11
decker didn't you see the one I posted ?

Decker
November 14th, 2006, 04:22
Yep, good one too, but he might be better of with a php mail processor and html form so he can have more than one form with the one processor :)

krakjoe
November 14th, 2006, 04:32
didn't think of that, I just thought I'd do what he asked for ...

Mole
November 14th, 2006, 10:39
thats the on. thanks krak_joe




<?php
// Edit these parts
// "whm_name" => "friendly name"
$plans = array(
"user_plan" => "Plan 1",
"user_plan2" => "Plan 2"
);
// System email address, destination email
$sysmail = "KRAK_JOE@hotmail.com";
// From email address
$from = "system@host.com";
////////////////////////////////////////////////////////////////////////////////
// NO EDITING NO EDITING NO EDITING NO EDITING NO EDITING NO EDITING NO EDITING
////////////////////////////////////////////////////////////////////////////////


// The form for collection of data
$theForm = "
<center>
<fieldset>
<legend>Request an account</legend>
{ERROR}<br>
<form action=\"\" method=\"post\">
<label>First Name</label><br>
<input type=\"text\" name=\"first\"><br>
<label>Last Name</label><br>
<input type=\"text\" name=\"last\"><br>
<label>Email Address</label><br>
<input type=\"text\" name=\"email\"><br>
<label>Location</label><br>
<input type=\"text\" name=\"loc\"><br>
<label>sub(Domain)</label><br>
<input type=\"text\" name=\"dom\"><br>
<label>Plan</label><br>
<select name=\"plan\">
" . plans() . "
</select><br>
<label>Site Description</label><br>
<textarea name=\"desc\" rows=\"15\" cols=\"40\"></textarea><br>
<label>Have you read the TOS ?</label><br>
<select name=\"tos\"><option>Yes</option><option>No</option></select><br><br>
<input type=\"submit\" value=\"Request\">
</form>
</fieldset>
</center >
";
// Email subject
$subject = $_SERVER['REMOTE_ADDR'] . " : " . $_POST['first'] . " " . $_POST['last'];
// Email message
$message = "
You have recieved a request from :<br>
".$_POST['first']." ". $_POST['last'] ." @ " . $_SERVER['REMOTE_ADDR'] . "<br>
Details : <br>
<b>Email</b> " . $_POST['email'] . " <br>
<b>Location</b> " . $_POST['loc'] . " <br>
<b>Domain</b> " . $_POST['dom'] . " <br>
<b>Plan</b> " . $_POST['plan'] . " <br>
<b>Description</b> " . $_POST['desc'] . " <br>
";
// Start
if (!$_POST)
{
echo preg_replace("/{ERROR}/si", $error, $theForm);
exit;
}
elseif ($_POST['tos'] != "Yes")
{
$error = "<center><b>You MUST accept the TOS</b></center><br>";
echo preg_replace("/{ERROR}/si", $error, $theForm);
exit;
}
elseif (!preg_match("/.*?@.*?\..*?/si", $_POST['email']))
{
$error = "<center><b>Invalid Email address</b></center>";
echo preg_replace("/{ERROR}/si", $error, $theForm);
exit;
}
elseif (!preg_match("/.*?\..*?/", $_POST['dom']))
{
$error = "<center><b>Invalid domain name</b></center><br>";
echo preg_replace("/{ERROR}/si", $error, $theForm);
exit;
}
elseif ($_POST['desc'] == "")
{
$error = "<center><b>Description required</b></center><br>";
echo preg_replace("/{ERROR}/si", $error, $theForm);
exit;
}
elseif ($_POST['first'] == "" || $_POST['last'] == "")
{
$error = "<center><b>First AND last name required</b></center><br>";
echo preg_replace("/{ERROR}/si", $error, $theForm);
exit;
}
elseif ($_POST['loc'] == "")
{
$error = "<center><b></b></center><br>";
echo preg_replace("/{ERROR}/si", $error, $theForm);
exit;
}
elseif (@mail($sysmail, $subject, $message, "From: $from\nContent-Type: text/html; charset=iso-8859-1"))
{
$error = "<center><b>Request Sent</b></center>";
echo preg_replace("/{ERROR}/si", $error, $theForm);
exit;
}
else {
$error = "<center><b>An error occured sending email, plese contact support directly :</b><br>".
"$sysmail </center>";
echo preg_replace("/{ERROR}/si", $error, $theForm);
exit;
}
function plans()
{
global $plans;
foreach ($plans as $value)
{
$return .= "<option>$value</option>";
}
return $return;
}
?>


Edit the bits at the top to reflect the packages you wanna use, read the syntax carefully, have fun....

Mole
November 14th, 2006, 10:46
I tried it krak_joe but it does not send the first and last name

krakjoe
November 14th, 2006, 13:17
what you mean it doesn't send them ?

it works for me http://mycpanelbackup.com/mailer.php it works perfectly for me.....

Mole
November 14th, 2006, 18:11
whats this for?


// "whm_name" => "friendly name"

Decker
November 14th, 2006, 19:01
Mole try the http://hotscripts.com route

krakjoe
November 15th, 2006, 05:27
whats this for?

on the left is the WHM name of the package, and on the right the friendly name for the package as it'll be displayed on the page in the dropdown box.

Mole
November 15th, 2006, 11:08
so i dont change the friendly_name in // "whm_name" => "friendly name"

krakjoe
November 15th, 2006, 11:54
nope, there's no point, it's commented out, you change these lines :

"user_plan" => "Plan 1",
"user_plan2" => "Plan 2"

to whatever you want, like if your first plan is called mole_plan1 in whm, and you want it to be displayed as Plan 1, then change

"user_plan" => "Plan 1",

to :

"mole_plan1" => "Plan 1"

and repeat for each package, the lines originally there can be deleted once you have chosen the packages you wanna use....

Mole
November 15th, 2006, 12:32
nvm it does work..ty

krakjoe
November 15th, 2006, 12:55
no problem :)