Barter Zone
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsGeneralBarter Zone

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today!
  #1  
Old November 25th, 2006, 01:42 PM
spycat spycat is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 2 spycat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
E-mailing form results to me

Ok, this is probably laughingly simple to the experts out here.
Go ahead and laugh, but can ya help me too...please?
Well, from that intro, you have probably gathered that I am not a PHP programmer.
Anyway, here it is:
I found a CAPTCHA script that I really liked. However, the author neglected to include code that would
take the input entered into the form and e-mail them to me.
I went looking around for other form handling scripts that sent the results in order to "piece it together" with the CAPTCHA
script. The thing is, most of these scripts get WAY to involved with their own validating processes and such, so
I can not get any to work.
I have a couple of little "send results to my email" snippets inserted into the code now, but like I said, they are not working.
Can someone please take a look at it and well...fix it?
I intend to learn PHP, but at this point, I just need the script to work.
Also, it is important that the "Thank You Page": "header("Location: http://www.metroactive.com/contact/thanks.html"); " remain functional.
I would be really grateful for this.
In the code I am providing, I will comment with :"Pieced in" on those parts that are from the 2nd script that sends form responses. All the rest of the code is from the "CAPTCHA" script.

Thanks folks

php Code:
Original - php Code
  1.  
  2. <?php
  3. if (isset($_POST['submit'])) {
  4. // clean and check form inputs including the secure image code
  5.     $name = trim(strip_tags($_POST['name']));
  6.     $email = trim(strip_tags($_POST['email']));
  7.     $phone = trim(strip_tags($_POST['phone']));
  8.     $event_title = trim(strip_tags($_POST['event_title']));
  9.     $event_date_and_time = trim(strip_tags($_POST['event_date_and_time']));
  10.     $event_location = trim(strip_tags($_POST['event_location']));
  11.     $event_phone_number = trim(strip_tags($_POST['event_phone_number']));
  12.     $event_price = trim(strip_tags($_POST['event_price']));
  13.     $event_description = trim(strip_tags($_POST['event_description']));
  14.    
  15.     $secure = strtoupper(trim(strip_tags($_POST['secure'])));
  16.     $match = $_SESSION['captcha']; // the code on the image
  17.  
  18. //Start Pieced in
  19. $MailToAddress = "rik408@yahoo.com";
  20. $MailSubject = "Club Event Submission";
  21.     if (!$MailFromAddress) {
  22.     $MailFromAddress = "$email";
  23.     }
  24. //end pieced in
  25.  
  26. // input error checking
  27.     if ($name=="") {
  28.         $err.= "Please provide your name<br/>";
  29.     }
  30.     if (!$email) {
  31.         $err.= "Please provide your email address<br>";
  32.     }
  33.     if ($email) {
  34.         if (!eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$", $email)) {
  35.             $err.= $email. " is not a valid email address.<br/>";
  36.         }
  37.     }
  38.     if ($phone=="") {
  39.         $err.= "Please provide your phone number<br/>";
  40.     }
  41.    
  42.     if ($event_title=="") {
  43.         $err.= "Please provide the title of the event<br/>";
  44.     }
  45.    
  46.     if ($event_date_and_time=="") {
  47.         $err.= "Please provide the date and time of the event<br/>";
  48.     }
  49.    
  50.     if ($event_location=="") {
  51.         $err.= "Please provide the location of the event<br/>";
  52.     }
  53.    
  54.     if ($event_phone_number=="") {
  55.         $err.= "Please provide a phone number for the venue<br/>";
  56.     }
  57.    
  58.     if ($event_price=="") {
  59.         $err.= "Please provide the price to attend the event<br/>";
  60.     }
  61.    
  62.     if ($event_description=="") {
  63.         $err.= "Please provide a description for the event<br/>";
  64.     }
  65.    
  66.    
  67.    
  68.    
  69.      if (!$secure) {
  70.         $err.= "No security code entered<br/>";
  71.     }
  72.     if (($secure!=$match) && ($secure!="")) {
  73.         $err.= "Security code mismatch<br/>";
  74.     }
  75.     if ($err=="") {
  76.  
  77.     //start pieced in: this may be a major trouble spot, since it is preceeded by another "if" statement
  78.     if (!is_array($HTTP_POST_VARS))
  79.     return;
  80. reset($HTTP_POST_VARS);
  81.     while(list($key, $val) = each($HTTP_POST_VARS)) {
  82.     $GLOBALS[$key] = $val;
  83.     $val=stripslashes($val);
  84.     echo  "<b>$key</b> = $val<br>";
  85.     $Message .= "$key = $valn";
  86.     }
  87.  
  88.    
  89. mail( "$MailToAddress", "$MailSubject", "$Message", "From: $MailFromAddress");
  90.  
  91.  
  92.     header("Location: http://www.metroactive.com/contact/thanks.html");
  93. //end pieced in
  94.     exit();
  95.     }
  96. }
  97.  
  98. ?>
  99. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  100. <html xmlns="http://www.w3.org/1999/xhtml">
  101. <head>
  102. <title>Trolls go away</title>
  103. <style type="text/css">
  104. body,td {
  105.     font-family:arial, helvetica, sans-serif;
  106.     background:#fff;
  107.     color:#000;
  108.     font-size:12px;
  109. }
  110. input, textarea {
  111.     background:#eee;
  112.     color:#000;
  113.     font-size:12px;
  114.     border:1px solid #000;   
  115.  }
  116. </style>
  117. </head>
  118. <body>
  119. <?php
  120. if ($err!="") {
  121.     echo "<strong>Form Error(s)</strong><br/>";
  122.     echo "<font color='#cc3300'>". nl2br($err). "</font><br/>";
  123. }
  124. ?>
  125.  
  126. <form name="captcha" method="post" action="<?php echo $_SERVER['SCRIPT_NAME'];?>">
  127. <table cellpadding="3" cellspacing="2" style="border:1px dotted #667;">
  128. <tr>
  129. <td>Name:</td><td><input type="text" name="name" value="<?php echo $_POST['name'];?>"/></td>
  130. </tr>
  131. <tr>
  132. <td>Email:</td><td><input type="text" name="email" value="<?php echo $_POST['email'];?>"/></td>
  133. </tr>
  134. <tr>
  135. <td>Daytime Phone: </td>
  136. <td><input type="text" name="phone" value="<?php echo $_POST['phone'];?>"/></td>
  137. </tr>
  138. <tr>
  139. <td>Club Event Title:</td><td><input type="text" name="event_title" value="<?php echo $_POST['event_title'];?>"/></td>
  140. </tr>
  141. <tr>
  142. <td>Date and Time:</td><td><input type="text" name="event_date_and_time" value="<?php echo $_POST['event_date_and_time'];?>"/></td>
  143. </tr>
  144. <tr>
  145. <td>Location:</td><td><input type="text" name="event_location" value="<?php echo $_POST['event_location'];?>"/></td>
  146. </tr>
  147. <tr>
  148. <td>Venue Phone Number:</td><td><input type="text" name="event_phone_number" value="<?php echo $_POST['event_phone_number'];?>"/></td>
  149. </tr>
  150. <tr>
  151. <td>Price</td><td><input type="text" name="event_price" value="<?php echo $_POST['event_price'];?>"/></td>
  152. </tr>
  153. <tr>
  154. <td valign="top">Event Description:</td><td><textarea rows="5" columns="30" name="event_description"><?php echo $_POST['event_description'];?></textarea></td>
  155. </tr>
  156. <tr>
  157.  
  158. <td>Security Code</td><td><input type="text" name="secure"/></td>
  159. </tr>
  160. <tr>
  161. <td><img src="captcha_image.php" alt="security image" border="0"/></td><td>
  162. <input type="submit" name="submit" value="Send"/></td>
  163. </tr>
  164. </table>
  165. </form>
  166. </body>
  167. </html>

Reply With Quote
  #2  
Old November 27th, 2006, 08:27 AM
System System is offline
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Posts: 665 System User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Message Moved

Thread moved from 'PHP Coding' to 'Barter Zone' by lig.

Reason: requests someone "fix it" for them

Reply With Quote
  #3  
Old November 27th, 2006, 11:12 AM
spycat spycat is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 2 spycat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: E-mailing form results to me

Dude, when I said "fix it", I was speaking in hyperbole.

Reply With Quote
Reply

Viewing: Codewalkers ForumsGeneralBarter Zone > E-mailing form results to me


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |