Jump to content

My feedback form will not show one submitted answer when sent


Elvardo

Recommended Posts

I used a script from the site wizard to create a feedback form for my website. I modified it to include 2 extra fields. When the form is sent not all of the info is sent. The name is OK, the email, the thumb has no value, & the item is OK. I added the thumb & item boxes to the script. I don't have any training with script writing i only dabble & a lot of what i do is trail & error. I have been reading a lot about this but cannot see the reason why the thumb value is blank when sent. Also i am trying to ensure all fields have a value before being sent, the original script from the site wizard works but it doesn't for the 2 fields i have added.

 

Can some one please take a look at the sciprt & tell me where i'm going wrong?

 

This is the PHP script, the code highlighted in red I tried to add extra code to include thumb_number & item but the form would not send even with all the fields filled in it would just goto the error page.

 

Do i need to post the html script?

 

Thanks is advance

 

<?php

/*

  */

 

// ------------- CONFIGURABLE SECTION ------------------------

 

// $mailto - set to the email address you want the form

// sent to, eg

//$mailto = "[email protected]" ;

 

$mailto = '[email protected]' ;

 

// $subject - set to the Subject line of the email, eg

//$subject = "Feedback Form" ;

 

$subject = "Feedback Form" ;

 

// the pages to be displayed, eg

//$formurl = "http://www.example.com/feedback.html" ;

//$errorurl = "http://www.example.com/error.html" ;

//$thankyouurl = "http://www.example.com/thankyou.html" ;

 

$formurl = "http://www.pensgems.co.uk/feedback.html" ;

$errorurl = "http://www.pensgems.co.uk/error.html" ;

$thankyouurl = "http://www.pensgems.co.uk/thankyou.html" ;

 

$email_is_required = 1;

$name_is_required = 1;

$comments_is_required = 1;

$thumb_number_is_required = 1;

$item_is_required = 1;

$uself = 0;

$use_envsender = 0;

$use_sendmailfrom = 0;

$use_webmaster_email_for_from = 0;

$use_utf8 = 1;

$my_recaptcha_private_key = '' ;

 

// -------------------- END OF CONFIGURABLE SECTION ---------------

 

$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;

$content_type = (!isset( $use_utf8 ) || ($use_utf8 == 0)) ? 'Content-Type: text/plain; charset="iso-8859-1"' : 'Content-Type: text/plain; charset="utf-8"' ;

if (!isset( $use_envsender )) { $use_envsender = 0 ; }

if (isset( $use_sendmailfrom ) && $use_sendmailfrom) {

ini_set( 'sendmail_from', $mailto );

}

$envsender = "-f$mailto" ;

$fullname = (isset($_POST['fullname']))? $_POST['fullname'] : $_POST['name'] ;

$email = $_POST['email'] ;

$thumb_number = $_POST['thumb_number'] ;

$item = $_POST['item'] ;

$comments = $_POST['comments'] ;

$http_referrer = getenv( "HTTP_REFERER" );

 

if (!isset($_POST['email'])) {

header( "Location: $formurl" );

exit ;

}

if (($email_is_required && (empty($email) || !preg_match('/@/', $email))) || ($name_is_required && empty($fullname)) || ($comments_is_required && empty($comments))) {

header( "Location: $errorurl" );

exit ;

}

if ( preg_match( "/[\r\n]/", $fullname ) || preg_match( "/[\r\n]/", $email ) ) {

header( "Location: $errorurl" );

exit ;

}

if (strlen( $my_recaptcha_private_key )) {

require_once( 'recaptchalib.php' );

$resp = recaptcha_check_answer ( $my_recaptcha_private_key, $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field'] );

if (!$resp->is_valid) {

header( "Location: $errorurl" );

exit ;

}

}

if (empty($email)) {

$email = $mailto ;

}

$fromemail = (!isset( $use_webmaster_email_for_from ) || ($use_webmaster_email_for_from == 0)) ? $email : $mailto ;

 

if (function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc()) {

$comments = stripslashes( $comments );

}

 

$messageproper =

"This message was sent from:\n" .

"$http_referrer\n" .

"------------------------------------------------------------\n" .

"Name of sender: $fullname\n" .

"Email of sender: $email\n" .

"Thumb Number: $thumb_number\n" .

"Item: $item\n" .

"------------------------- COMMENTS -------------------------\n\n" .

$comments .

"\n\n------------------------------------------------------------\n" ;

 

$headers =

"From: \"$fullname\" <$fromemail>" . $headersep . "Reply-To: \"$fullname\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.15.0" .

$headersep . 'MIME-Version: 1.0' . $headersep . $content_type ;

 

if ($use_envsender) {

mail($mailto, $subject, $messageproper, $headers, $envsender );

}

else {

mail($mailto, $subject, $messageproper, $headers );

}

header( "Location: $thankyouurl" );

exit ;

 

?>

Thanks for the reply, would you belive it I opened the sript tp copy & paste & found the error...

<td><input type="text" name="thumbnumber" id="tswthumb" size="10" /></td></tr>

changed it to <td><input type="text" name="thumb_number" id="tswthumb" size="10" /></td></tr>

 

But I'm still stuck as to why the 2 added fields will send regardless of the field having a value or not?

 

I will post the html script any way....

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

 

<title>contactus</title>

 

<link href="twoColLiqLtHdr.css" rel="stylesheet" type="text/css" />

<!--[if IE]>

<style type="text/css">

/* place css fixes for all versions of IE in this conditional comment */

.twoColLiqLtHdr #sidebar1 { padding-top: 30px; }

.twoColLiqLtHdr #mainContent { zoom: 1; padding-top: 15px; }

/* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */

</style>

<![endif]-->

<style type="text/css">

<!--

.style1 {

color: #920792

}

-->

</style>

<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>

<link href="SpryAssets/SpryMenuBarVertical.css" rel="stylesheet" type="text/css" />

<style type="text/css">

ul.MenuBarVertical

{

margin: 0 auto ;

width: 8em;

}

.style4 {color: #9900CC}

</style>

</head>

 

<body class="twoColLiqLtHdr">

 

<div id="container">

  <div id="header">

    <h1 align="left" class="style1"><img src="logopurple.gif" width="126" height="106" alt="logo" /></h1>

    <!-- end #header --></div>

  <div id="sidebar1">

    <p> </p>

    <ul id="MenuBar1" class="MenuBarVertical">

      <li><a href="index.html">Home</a></li>

      <li><a href="aboutus.html">About Us</a></li>

      <li><a href="photos.html">Jewellery</a> </li>

      <li><a href="feedback.html">Contact Us</a></li>

    </ul>

    <p> </p>

    <p>

      <!-- end #sidebar1 -->

    </p>

  </div>

  <div id="mainContent">

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

      <p>Please use this form to  send either your feedback

      or

      if you would like more information.

      To purchase  a particular piece of jewellery please

      include the number of the thumb nail

      and

      the corresponding item.</p>

      <table border="0" cellpadding="8" cellspacing="8" summary="feedback form">

<tr><td><label for="tswname"><span class="style4">Name</span></label>

  <span class="style4">:</span></td>

<td><input type="text" name="fullname" id="tswname" size="25" /></td></tr>

<tr><td><label for="tswemail"><span class="style4">Email address</span></label>

  <span class="style4">:</span></td>

<td><input type="text" id="tswemail" name="email" size="25" /></td></tr>

<tr><td><label for="tswthumb"><span class="style4">Thumb Number</span></label>

  <span class="style4">:</span></td>

<td><input type="text" name="thumb_number" id="tswthumb" size="10" /></td></tr>

<tr><td><label for="tswitem"><span class="style4">Item</span></label>

  <span class="style4">:</span></td>

<td><input type="text" name="item" id="tswitem" size="10" /></td></tr>

<tr>

<td colspan="2">

<label for="tswcomments"><span class="style4">Comments</span></label>

<span class="style4"> :</span><br />

<textarea rows="15" cols="45" name="comments" id="tswcomments"></textarea></td>

</tr>

<tr>

<td align="center" colspan="2">

<input type="submit" class="style4" value="Send Comments" />

<br />

</td>

</tr>

</table>

</form>

 

   

    <p> </p>

    <!-- end #mainContent --></div>

<!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats --><br class="clearfloat" />

  <div id="footer">

    <p>©PensGems</p>

    <!-- end #footer --></div>

<!-- end #container --></div>

<script type="text/javascript">

<!--

var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});

//-->

</script>

</body>

</html>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>contactus</title>

<link href="twoColLiqLtHdr.css" rel="stylesheet" type="text/css" />
<!--[if IE]>
<style type="text/css"> 
/* place css fixes for all versions of IE in this conditional comment */
.twoColLiqLtHdr #sidebar1 { padding-top: 30px; }
.twoColLiqLtHdr #mainContent { zoom: 1; padding-top: 15px; }
/* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
</style>
<![endif]-->
<style type="text/css">
<!--
.style1 {
   color: #920792
}
-->
</style>
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<link href="SpryAssets/SpryMenuBarVertical.css" rel="stylesheet" type="text/css" />
<style type="text/css">
ul.MenuBarVertical
{
   margin: 0 auto ;
   width: 8em;
}
.style4 {color: #9900CC}
</style>
</head>

<body class="twoColLiqLtHdr">

<div id="container"> 
  <div id="header">
    <h1 align="left" class="style1"><img src="logopurple.gif" width="126" height="106" alt="logo" /></h1>
    <!-- end #header --></div>
  <div id="sidebar1">
    <p> </p>
    <ul id="MenuBar1" class="MenuBarVertical">
      <li><a href="index.html">Home</a></li>
      <li><a href="aboutus.html">About Us</a></li>
      <li><a href="photos.html">Jewellery</a> </li>
      <li><a href="feedback.html">Contact Us</a></li>
    </ul>
    <p> </p>
    <p>
      <!-- end #sidebar1 -->
    </p>
  </div>
  <div id="mainContent">
    <form action="feedback.php" method="post">
      <p>Please use this form to  send either your feedback
      or 
      if you would like more information.
      To purchase  a particular piece of jewellery please 
      include the number of the thumb nail 
      and 
      the corresponding item.</p>
      <table border="0" cellpadding="8" cellspacing="8" summary="feedback form">
<tr><td><label for="tswname"><span class="style4">Name</span></label>
  <span class="style4">:</span></td>
<td><input type="text" name="fullname" id="tswname" size="25" /></td></tr>
<tr><td><label for="tswemail"><span class="style4">Email address</span></label>
  <span class="style4">:</span></td>
<td><input type="text" id="tswemail" name="email" size="25" /></td></tr>
<tr><td><label for="tswthumb"><span class="style4">Thumb Number</span></label>
  <span class="style4">:</span></td>
<td><input type="text" name="thumb_number" id="tswthumb" size="10" /></td></tr>
<tr><td><label for="tswitem"><span class="style4">Item</span></label>
  <span class="style4">:</span></td>
<td><input type="text" name="item" id="tswitem" size="10" /></td></tr>
<tr>
<td colspan="2">
<label for="tswcomments"><span class="style4">Comments</span></label>
<span class="style4"> :</span><br />
<textarea rows="15" cols="45" name="comments" id="tswcomments"></textarea></td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="submit" class="style4" value="Send Comments" />
<br />
</td>
</tr>
</table>
</form>

    
    <p> </p>
    <!-- end #mainContent --></div>
   <!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats --><br class="clearfloat" />
  <div id="footer">
    <p>©PensGems</p>
    <!-- end #footer --></div>
<!-- end #container --></div>
<script type="text/javascript">
<!--
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
//-->
</script>
</body>
</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.