Skip to main content
GameDev.net gamedev.net
🔒 Locked 🤖 Godot

[web] PHP email form problem

Started by blackbirdblackbird1 Jun 16, 2007 at 1:27 PM 0 replies 750+ views
Original Post
blackbirdblackbird1
blackbirdblackbird1
It seems that the email form does work (because it DOES email me) but it seems that it is not collecting the information from the form. Here is my email form code:

28		
29 <form method='post' action="<?= $_SERVER['PHP_SELF'] ?>"> 30

31 <?php 32 $ipi = getenv("REMOTE_ADDR"); 33 $httprefi = getenv ("HTTP_REFERER"); 34 $httpagenti = getenv ("HTTP_USER_AGENT"); 35 ?> 36 37 <input type="hidden" name="ip" value="<?php echo $ipi ?>" /> 38 <input type="hidden" name="httpref" value="<?php echo $httprefi ?>" /> 39 <input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" /> 40 <input type="hidden" name="subject" value="Mailing List addition - Graduation DVD" /> 41 <font color='#000000'>Would you like to be added to the mailing list for updates on the Grad DVD? Just enter your email here >></font> 42 <input name="email" class="textbox" type="text" /> 43 <input name="submit" class="button" value="Submit" type="submit" /> 44

45 </form> 46 47
Here is the emailer code:

150 <?php
151 $aErrors = array();
152 if (!ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', $_REQUEST['email']))
153 {
154 $aErrors[] = "";
155 }
156
157 if (count($aErrors)) {
158	$sURL = "grad.php?m=" . urlencode(implode("
", $aErrors)); 159 foreach ($_REQUEST as $rName => $rValue) $sURL .= "&" . 11 urlencode($rName) . "=" . urlencode($rValue); 160 header("Location: {$sURL}"); 161 exit; 162 } 163 164 ?> 165 166 167 <? 168 169 $todayis = date("l, F j, Y, g:i a") ; 170 171 172 173 $subject = $attn; 174 175 $notes = stripcslashes($message); 176 177 $message = " $todayis [PST] \n 178 179 From: $email \n 180 181 Message: $email has requested to be added to the Graduation DVD mailing list. \n 181 182 183 184 Additional Info : IP = $ip \n 185 Browser Info: $httpagent \n 186 Referral : $httpref \n 187 "; 188 189 $from = "From: $email\r\n"; 190 191 192 mail("gradmail.labsply.com", $subject, $message, $from); 193 194 ?>
I have made several other email forms using php and never had this problem before.
++++++++++++++++++++++++++++++++++++++++++AMD Phenom 9600 Quad Core (2.2 GHz x 4)4 GB Corsair XMS2 DDR2 800 RAMnVidia 8400 (512 MB, PCI-E 16x)Westinghouse 32" LCD monitor @ 1366x768 / 1280x1024160 GB (7200 RPM) SATA HDD120 GB (7200 RPM) IDE HDDWeb Developer (XHTML/CSS/MySQL/PHP/ASP)**Beginning
deadimp
deadimp
You don't seem to be getting the form data, nor do you even seem to be checking if any information has been submitted. You might be relying on an old feature, 'register_globals', that automatically declared variables namely in $_GET and $_POST as globals. Since a certain version (don't know which), it's disabled by default, and it's better that way.
For checking a submission (since it's the same file, you'll need to do that), just check if a certain field that you know will be filled if is not null, or the key exists in $_POST / $_GET.

On a side note, some of your code doesn't seem to be consistent. You switch between $_SERVER and getenv() to get environment information - both of which are the same thing. Plus, you switch between and , of the two the first is better. These aren't anything big, just might want to make your code a little more uniform.
To add to that, you can use CSS selectors for your inputs - though I don't know about IE 6 compatibility.
Projects:> Thacmus - CMS (PHP 5, MySQL)Paused:> dgi> MegaMan X Crossfire

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.