Jump to content

Recommended Posts

Posted

I have this script for a feedback form that I generated on a site and I need to learn how to modify it to do what I need to be done.

 

http://www.everythingdarts.com/Templates/contact.html

If you look on that site, you will notice there are 7 possible recipients of the message and the script I have only deals with the form going to one person. how can i modify this script to allow for the radio buttons to decide the proper recipient? I also need to be taught what to put with the radio buttons as I have not learned what would go there to work this yet.

 

this is the html code for the form that only goes to one person

><form action="feedback.php" method="post">
<table border="0" cellpadding="8" cellspacing="8" summary="feedback form">
<tr><td><label for="tswname">Name</label>:</td><td><input type="text" name="fullname" id="tswname" size="25" /></td></tr>
<tr><td><label for="tswemail">Email address</label>:</td><td><input type="text" id="tswemail" name="email" size="25" /></td></tr>
<tr>
<td colspan="2">
<label for="tswcomments">Comments</label><br />
<textarea rows="15" cols="45" name="comments" id="tswcomments"></textarea>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="submit" value="Send Feedback" /><br />
Form by <a href="http://www.thesitewizard.com/">thesitewizard.com</a>
</td>
</tr>
</table>
</form>

 

this is the feedback.php

><?php
/*
   CHFEEDBACK.PHP Feedback Form PHP Script Ver 2.15.0
   Generated by thesitewizard.com's Feedback Form Wizard 2.15.0.
   Copyright 2000-2009 by Christopher Heng. All rights reserved.
   thesitewizard is a trademark of Christopher Heng.

   Get the latest version, free, from:
       http://www.thesitewizard.com/wizards/feedbackform.shtml

You can read the Frequently Asked Questions (FAQ) at:
	http://www.thesitewizard.com/wizards/faq.shtml

I can be contacted at:
	http://www.thesitewizard.com/feedback.php
Note that I do not normally respond to questions that have
already been answered in the FAQ, so *please* read the FAQ.

   LICENCE TERMS
   
   1. You may use this script on your website, with or
   without modifications, free of charge.
   
   2. You may NOT distribute or republish this script,
   whether modified or not. The script can only be
   distributed by the author, Christopher Heng.
   
   3. THE SCRIPT AND ITS DOCUMENTATION ARE PROVIDED
   "AS IS", WITHOUT WARRANTY OF ANY KIND, NOT EVEN THE
   IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A
   PARTICULAR PURPOSE. YOU AGREE TO BEAR ALL RISKS AND
   LIABILITIES ARISING FROM THE USE OF THE SCRIPT,
   ITS DOCUMENTATION AND THE INFORMATION PROVIDED BY THE
   SCRIPTS AND THE DOCUMENTATION.

   If you cannot agree to any of the above conditions, you
   may not use the script. 
   
   Although it is not required, I would be most grateful
   if you could also link to thesitewizard.com at:

      http://www.thesitewizard.com/

*/

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

// $mailto - set to the email address you want the form
// sent to, eg
//$mailto		= "youremailaddress@example.com" ;

$mailto = 'extreme@tregonia.net' ;

// $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.everythingdarts.com/Templates/contact.html" ;
$errorurl = "http://www.everythingdarts.com/Templates/feedbackerror.html" ;
$thankyouurl = "http://http://www.everythingdarts.com/Templates/feedbackthankyou.html" ;

$email_is_required = 1;
$name_is_required = 1;
$comments_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'] ;
$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" .
"------------------------- 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 ;

?>

 

I am going to school for webdesign, but i dont begin working with php till my second year which will be after the new year. any help would be great as i am learning.

Posted

wow. i was merely asking how to edit an existing file. you could have just said do it yourself. i will ask any scripting question from now on elsewhere. Sorry i wasted your time

Posted

Using that script and your script together and modifying them both seems like a bit of a waste of time to me - they aren't very compatible as they use different field names and expect a different number of fields etc. I would rebuild it from scratch personally. I don't even think that PHP form processor is very good. It's not very intuitive at least. I am a freelance PHP developer so if you would like any assistance please PM me and I will see if I can help.

Posted (edited)

Add the following to the form.

><input type="radio" name="whoto" value="1" id="whoto1" checked="checked">
<label for="whoto1">Person 1</a><br><input type="radio" name="whoto" value="2" id="whoto2">
<label for="whoto2">Person 2</a><br><input type="radio" name="whoto" value="3" id="whoto3">
<label for="whoto3">Person 3</a><br><input type="radio" name="whoto" value="4" id="whoto4">
<label for="whoto4">Person 4</a><br><input type="radio" name="whoto" value="5" id="whoto5">
<label for="whoto5">Person 5</a><br>

 

Then to the script we need to add something like

 

>
if (!isset($_POST['whoto'])) {
header( "Location: $formurl" );
exit ;
}
$recipients = array(
1 => 'email@address1.com',
2 => 'email@address2.com',
3 => 'email@address3.com',
4 => 'email@address4.com',
5 => 'email@address5.com'
);
$sendto = intval($_POST['whoto']);
$mailto = (($sendto > 0) && ($sendto <= count($recipients)) ? $recipients[$sendto] : $mailto;

 

Totally untested and you need to leave the current $mailto = '....'; bit in place as it uses that as a back up if someones playing silly buggers.

Edited by carbonize
Posted

I will test this out to see how she works. Its amazing how close php is to my old game script. But then again they are both made off C++. Should be easy for me to grasp it once I get to learning it

Posted

Now im no expert with php, but I did the plugging and formating, but sompething in this just doesnt look right. There is no mail function for one

>bool mail  (  string $to  ,  string $subject  ,  string $message  [,  string $additional_headers  [,  string $additional_parameters  ]] )

 

>  <div class="feedback">
<table>
<tr>
<td>
   <div id="leftbar" class="col300">
     <div id="recipient">
       <form id="form1" name="form1" method="post" action="">
	  <input type="radio" name="whoto" value="1" id="whoto1" checked="checked" /><br />
	  <label for="whoto1"><input type="radio" name="whoto" value="2" id="whoto2" />EverythingDartsAdmin</label><br />
	  <label for="whoto2"><input type="radio" name="whoto" value="3" id="whoto3" />Extreme</label><br />
	  <label for="whoto3"><input type="radio" name="whoto" value="4" id="whoto4" />Kowalski</label><br />
	  <label for="whoto4"><input type="radio" name="whoto" value="5" id="whoto5" />Buzz180</label><br />
         <label for="whoto5"><input type="radio" name="whoto" value="6" id="whoto6" />Slim180</label><br />
         <label for="whoto6"><input type="radio" name="whoto" value="7" id="whoto7" />Pestey</label><br />
         <label for="whoto7"><input type="radio" name="whoto" value="8" id="whoto8" />UJSupanova</label><br />
       </form>
     </div>
     <div id="bottons">
       <input name="submit" type="submit" value="Submit" />
       <input name="reset" type="reset" value="Reset Field" />
     </div>
   </div>
</td>
<td>
     <div id="textarea" class="right col300">
       <textarea name="text" cols="50" rows="10">Feel free to contact us</textarea>
  </div>
</td>
</tr>
</table> 
   </div>
   <?
  if (!isset($_POST['whoto'])) {
	header( "Location: $formurl" );
	exit ;
  }
  $recipients = array(
	'email@address1.com',
	'email@address2.com',
	'email@address3.com',
	'email@address4.com',
	'email@address5.com'
  );
  $sendto = intval($_POST['whoto']);
  $mailto = (($sendto > 0) && ($sendto <= count($recipients)) ? $recipients[$sendto] : $mailto;
?>

 

Where are my errors. Im trying to grasp this

Posted

yeah i knew of that one. i posted the sytax of it from php.net above the script. I just tried to make the mail snytax and noticed that this script is only handling the senders as requested. Didnt realize that till just now when I tried to add the function. I am going to have to look at this tonight, I work nights and its bedtime, and get back with you tomorrow.

 

I am going to read and try and finish this script now that I have something to work with. Im going to compare this to my knowledge of another scripting language similar to php. I know I need to add a input for Subject and return email. Actually have the email part in the html just not here. I will do what I can with the knowledge i possess and hopefully get your comments on this tomorrow

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...