How do I add a field to my feedback form

They have: 4 posts

Joined: Jan 2009

Hi, I have a guest feedback form at http://www.walkingenglishman.com/guestbookfeedback.htm which works very well but although I ask for peope to add their address (town/ city/ country) in the mail message they often miss doing so. How can I ad another field to the form so there is:

Your Name:
Your Address:
Your Email:
Mail Message:

Any help much appreciated.

pr0gr4mm3r's picture

He has: 1,502 posts

Joined: Sep 2006

What guestbook script are you using? You have a lot of unparsed PHP code in that form. That code should be in a php file, not an htm file.

They have: 4 posts

Joined: Jan 2009

Bear with me please as it was built for me by a third party. The page script is as follows:

0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i

and the form script is:

<?php
$ipi
= getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>

Your Name:

Your Email:

Mail Message (Please add your town/city and country):

They have: 4 posts

Joined: Jan 2009

The form script is:

<?php
$ipi
= getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>

Your Name:

Your Email:

Mail Message (Please add your town/city and country):

decibel.places's picture

He has: 1,494 posts

Joined: Jun 2008

Welcome to TWF, W.E. Laughing out loud

You need to enclose code in the <code> tags, the third icon from the right in the toolbar.

<form method="post" action="guestbookthankyou.php">

<!-- DO NOT change ANY of the php sections -->
<?php
$ipi
= getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>


<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />


<strong>Your Name:</strong> <br />
<input type="text" name="visitor" size="35" />
<br /><br />
<strong>Your Email:</strong><br />
<input type="text" name="visitormail" size="35" />
<br /> <br />
<strong>Mail Message <em>(Please add your town/city and country)</em>:</strong><br />
<textarea name="notes" rows="10" cols="100"></textarea>
<br />
<input type="submit" value="Send Mail" />
<br />
</form>

To add a field, follow the examples and give it a unique name

I would suggest something like this (I am using a textarea instead of a single line input):

<strong>Your Address:</strong><br />
<textarea name="visitoraddress" cols="100" rows="5" /></textarea>
<br /> <br />

Then check guestbookthankyou.php - you may need to add the new name to that script as $_POST['visitoraddress'] or $_REQUEST['visitoraddress'] (if you see the other field names set up like this, just follow the example)

some scripts will automatically grab all the $_POST values

if you can show us guestbookthankyou.php we can help you better Smiling

They have: 4 posts

Joined: Jan 2009

Sorry, being away, here is the guestbookthankyou.php you requested:

<?php
$ip
= $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$notes = $_POST['notes'];
$attn = $_POST['attn'];


if (
eregi('http:', $notes)) {
die (
"Do NOT try that! ! ");
}
if(!
$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo
"<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo
$badinput;
die (
"Go back! ! ");
}

if(empty(
$visitor) || empty($visitormail) || empty($notes )) {
echo
"<h2>Use Back - fill in all fields</h2>\n";
die (
"Use back! ! ");
}

$todayis = date("l, F j, Y, g:i a") ;

$attn = $attn ;
$subject = $attn;

$notes = stripcslashes($notes);

$message = " $todayis [EST] \n
Attention:
$attn \n
Message:
$notes \n
From:
$visitor ($visitormail)\n
Additional Info : IP =
$ip \n
Browser Info:
$httpagent \n
Referral :
$httpref \n
"
;

$from = "From: $visitormail\r\n";


mail("[email protected]", $subject, $message, $from);
?>



Date:
<?php
echo $todayis
?>

Thank You :

<?php
echo $visitor
?>
(
<?php
echo $visitormail
?>
)

Attention:

<?php
echo $attn
?>

Message:

<?php
$notesout
= str_replace("\r", "<br/>", $notes);
echo
$notesout;
?>

<?php
echo $ip
?>

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.