PDA

View Full Version : php form script


collie
08-08-2005, 07:17 PM
when I use <form action="mailto:xxxx@xxx.com" method="post" enctype="text/plain">

my form does what it is intended to.

When I try to use a php script I call simplescript.php I receive a msg. (results from form) and nothing else.

My html points to the php but nothing happens.
<FORM ACTION="SIMPLESCRIPT.PHP" METHOD="POST" ENCTYPE="TEXT/PLAIN">

Would you please take a look at this code for me?


<?php

// Simple Form Script
// Copyright (C) 2005 Eric Zhang
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// Please send bugs/questions to erkzh@yahoo.com.

//--------------------------Set these paramaters--------------------------


$subject = 'HOME LISTING'; // Subject of email sent to you.
$emailadd = 'rrobbins@ne.rr.com'; // Your email address. This is where the form information will be sent.
$url = 'http://www.southernskys.com'; // Where to redirect after form is processed.
$req = '0'; // Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.

// --------------------------Do not edit below this line--------------------------
$text = "Results from form:\n\n";
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>

Pennimus
08-08-2005, 10:26 PM
Can we see your form HTML as well please.

collie
08-09-2005, 08:10 PM
here is my html script,
thanks for looking




<html>
<head>
<title>table</title>
</head>

<body bgcolor=#000000>

<center>


<table border=2 width="70%" cellspacing=5 cellpadding=8 bgcolor=cyan cols=3>
<tr><td colspan=3 align=LEFT>SOUTHERNSKYS.COM <b><i>&nbsp &nbsp &nbsp will go beyond your needs to make it happen </i></b> </td></tr>


<table border=2 width="70%" cellspacing=5 cellpadding=5 bgcolor=cyan cols=3>
<tr><td colspan=2 align=center><i>HOME LISTING FORM <BR> <i> <b>Please fill in the informatiom and click the submit button bottom of page.</b> </i></td></tr>

<form action="mailto:rrobbins@ne.rr.com" method="post" enctype="text/plain">

<tr><td>FULL NAME:<input type="text" size="50" maxlength="60" name="name"></td></tr>

<tr><td>ADDRESS:<input type="address" size="50" maxlength="60" name="address"></td></tr>
</td></tr>
<tr><td>PHONE:<input type="phone" size="50" maxlength="60" name="phone"></td></tr>
</td></tr>
<tr><td>NAME OF PARK:<input type="name of park" size="50" maxlength="60" name="name of park"></td></tr>
</td></tr>
<tr><td>WHAT COUNTY:<input type="what county" size="50" maxlength="60" name="what county"></td></tr>
</td></tr>
<tr><td>ASKING PRICE:<input type="asking price" size="50" maxlength="60" name="asking price"></td></tr>
</td></tr>
<tr><td>BEDROOMS:<input type="bedrooms" size="50" maxlength="60" name="bedrooms"></td></tr>
</td></tr>
<tr><td>BATHROOMS:<input type="bathrooms" size="50" maxlength="60" name="bathrooms"></td></tr>
</td></tr>
<tr><td>CARPORT:<input type="carport" size="50" maxlength="60" name="carport"></td></tr>
</td></tr>
<tr><td>WASHER/DRYER:<input type="washer/dryer" size="50" maxlength="60" name="washer/dryer"></td></tr>
</td></tr>
<tr><td>LANIE:<input type="lanie" size="50" maxlength="60" name="lanie"></td></tr>
</td></tr>
<tr><td>YEAR OF HOME:<input type="year of home" size="50" maxlength="60" name="year of home"></td></tr>
</td></tr>
<tr><td>MAKE OF HOME:<input type="makkke of home" size="50" maxlength="60" name="make of home"></td></tr>
</td></tr>
<tr><td>FURNISHED:<input type="furnished" size="50" maxlength="60" name="furnished"></td></tr>
</td></tr>
<tr><td>LOT RENT/INCLUDES WHAT:<input type="lot rent/includes what" size="50" maxlength="60" name="lot rent/includes what"></td></tr>
</td></tr>
<tr><td>HOME CONDITION:<input type="home condition" size="50" maxlength="60" name="home condition"></td></tr>
</td></tr>
<tr><td>CENTRAL HEAT:<input type="central heat" size="50" maxlength="60" name="central heat"></td></tr>
</td></tr>
<tr><td>CENTRAL AIR:<input type="central air" size="50" maxlength="60" name="central air"></td></tr>
</td></tr>
<tr><td>FURNISHINGS:<input type="furnishings" size="50" maxlength="60" name="furnishings"></td></tr>
</td></tr>
<tr><td>ADULT PARK 55+ OR OTHER:<input type="adult park 55+ or other" size="50" maxlength="60" name="adult park 55+ or other"></td></tr>
</td></tr>
<tr><td>SWIMMING POOL:<input type="swimming pool" size="50" maxlength="60" name="swimming pool"></td></tr>
</td></tr>
<tr><td>CLUB HOUSE:<input type="club house" size="50" maxlength="60" name="club house"></td></tr>
</td></tr>
<tr><td>GATED:<input type="gated" size="50" maxlength="60" name="gated"></td></tr>
</td></tr>
<tr><td>PETS:<input type="pets" size="50" maxlength="60" name="pets"></td></tr>
</td></tr>
<tr><td>ROOF STYLE:<input type="roof style" size="50" maxlength="60" name="roof style"></td></tr>
</td></tr>
<tr><td>OTHER FEATURES:<input type="other features" size="50" maxlength="70" name="other features"></td></tr>

<tr><td>MESSAGE:<textarea name='msg' rows='4' cols='50'></textarea></td></tr>
<tr>
<td>
<input type="submit" value="submit">
<input type="reset" name="reset" value="reset">
</td></tr>

</table></form>

</html>

Pennimus
08-09-2005, 10:28 PM
I confess I don't quite get the script you've got there. I can see what it's trying to do but can't decipher how it does it or where it's going wrong. In this position I would change your formhandler to one that doesn't automatically pick up the fields. But given the huge number of form fields you have I can see why you wouldn't want to do this. Somebody a little more experienced is going to have to take it from here...

collie
08-09-2005, 11:26 PM
Sorry the first line <form action="mailto:xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>

should read <form action="simplescript.php" method="post" enctype="text/plain">

where simplescript points to my php file