bad03xtreme Posted September 26, 2008 Share Posted September 26, 2008 I am working on a form for a conference registration for my mom but I can't get the dam thing to work no matter what I do. I just need the form to submit all of the information through email so it can be submitted by the recipient into a database. I have created the PHP but I cannot figure out how to get multiple items into the body of the email when submitted. Any idea of what I am doing wrong? ??? This is the PHP. The form is here: http://www.vaea.k12.va.us/form.html <?php # Don't put anything above the previous line, not even blank space #require "captcha.php"; require '/home/boutell/html/tools/captcha/captcha.php'; # The person who receives the email messages #$recipient = '[email protected]'; $recipient = '[email protected]'; # Usually $_SERVER['SERVER_NAME'] is fine, but if you have an unusual # hosting setup, you might need to set this manually to 'www.vaea.k12.va.us' #$serverName = $_SERVER['SERVER_NAME']; $serverName = 'www.vaea.k12.va.us'; if ($_POST['send']) { sendMail(); } elseif (($_POST['cancel']) || ($_POST['continue'])) { redirect(); } else { displayForm(false); } function displayForm($messages) { # Import $login object from accountable. If we're not using # accountable this is null, which is not a problem global $login; # Re-display existing input so that the user doesn't have to enter # things again when correcting a problem with just one field. # Make sure ", <, >, etc. entered by the user are not treated # as part of the HTML of the page # If the email address and real name haven't been entered yet, # check $_SESSION for them. If Accountable is in use, we can # pre-fill these fields for the user. $escapedEmail = htmlspecialchars($_POST['email']); $escapedRealName = htmlspecialchars($_POST['realname']); $escapedSubject = htmlspecialchars($_POST['subject']); $escapedBody = htmlspecialchars($_POST['body']); $returnUrl = $_POST['returnurl']; if (!strlen($returnUrl)) { # We'll return the user to the page they came from $returnUrl = $_SERVER['HTTP_REFERER']; if (!strlen($returnUrl)) { # Stubborn browser won't give us a referring # URL, so return to the home page of our site instead $returnUrl = '/'; } } $escapedReturnUrl = htmlspecialchars($returnUrl); # Shift back into HTML mode to send the form ?> <html> <head> <?php } ?> <title>Regestration</title> </head> <body> <h1>2009 VAEA Conference Registration</h1> <form method="POST" action="<?php echo $_SERVER['DOCUMENT_URL']?>"> <p> <input name="name" size="64" maxlength="64" value="<?php echo $escapedName?>"/> Your Name </p> <p> <input name="title" size="64" maxlength="64" value="<?php echo $escapedTitle?>"/> Title </p> <p> <input name="email" size="64" maxlength="64" value="<?php echo $escapedEmail?>"/> Email Address </p> <p> Mailing Address </p> <textarea name="address" rows="2" cols="60"><?php echo $escapedAddress?></textarea> <p> <input name="phone" size="64" maxlength="64" value="<?php echo $escapedPhone?>"/> Phone Number </p> <p> <input name="school" size="64" maxlength="64" value="<?php echo $escapedSchool?>"/> School/Program Name </p> <p> <select name="grade"> <option value="k">K</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> </select>Grade level(s) </p> <p> <select name="county"> <option value="Accomack County">Accomack County Public Schools</option> <option value="Albemarle County">Albemarle County Public Schools</option> <option value="Alexandria City">Alexandria City Public Schools</option> <option value="Alleghany County">Alleghany County Public Schools</option> <option value="Amelia County">Amelia County Public Schools</option> <option value="Amherst County">Amherst County Public Schools</option> <option value="Appomattox County">Appomattox County Public Schools</option> <option value="Arlington County">Arlington County Public Schools</option> <option value="Augusta County">Augusta County Public Schools</option> <option value="Bath County">Bath County Public Schools</option> <option value="Bedford City">Bedford City Public Schools</option> <option value="Bedford County">Bedford County Public Schools</option> <option value="Bland County">Bland County Public Schools</option> <option value="Botetourt County">Botetourt County Public Schools</option> <option value="Bristol City">Bristol City Public Schools</option> <option value="Brunswick County">Brunswick County Public Schools</option> <option value="Buchanan County">Buchanan County Public Schools</option> <option value="Buckingham County">Buckingham County Public Schools</option> <option value="Buena Vista City">Buena Vista City Public Schools</option> <option value="Campbell County">Campbell County Public Schools</option> <option value="Caroline County">Caroline County Public Schools</option> <option value="Carroll County">Carroll County Public Schools</option> <option value="Charles City">Charles City County Public Schools</option> <option value="Charlotte County">Charlotte County Public Schools</option> <option value="Charlottesville City">Charlottesville City Public Schools</option> <option value="Chesapeake City">Chesapeake City Public Schools</option> <option value="Chesterfield County">Chesterfield County Public Schools</option> <option value="Clarke County">Clarke County Public Schools</option> <option value="Chesterfield County">Chesterfield County Public Schools</option> <option value="Colonial Beach">Colonial Beach Public Schools</option> <option value="Colonial Heights">Colonial Heights City Public Schools</option> <option value="Covington City">Covington City Public Schools</option> <option value="Craig County">Craig County Public Schools</option> <option value="Culpeper County">Culpeper County Public Schools</option> <option value="Cumberland County">Cumberland County Public Schools</option> <option value="Danville City">Danville City Public Schools</option> <option value="Dickenson County">Dickenson County Public Schools</option> <option value="Dinwiddie County">Dinwiddie County Public Schools</option> <option value="Emporia">Emporia</option> <option value="Essex County">Essex County Public Schools</option> <option value="Fairfax City">Fairfax City Public Schools</option> <option value="Fairfax County">Fairfax County Public Schools</option> <option value="Falls Church City">Falls Church City Public Schools</option> <option value="Fauquier County">Fauquier County Public Schools</option> <option value="Floyd County">Floyd County Public Schools</option> <option value="Fluvanna County">Fluvanna County Public Schools</option> <option value="Franklin City">Franklin City Public Schools</option> <option value="Franklin County">Franklin County Public Schools</option> <option value="Frederick County">Frederick County Public Schools</option> <option value="Fredericksburg City">Fredericksburg City Public Schools</option> <option value="Galax City">Galax City Public Schools</option> <option value="Giles County">Giles County Public Schools</option> <option value="Gloucester County">Gloucester County Public Schools</option> <option value="Goochland County">Goochland County Public Schools</option> <option value="Grayson County">Grayson County Public Schools</option> <option value="Greene County">Greene County Public Schools</option> <option value="Halifax County">Halifax County Public Schools</option> <option value="Hampton City">Hampton City Public Schools</option> <option value="Hanover County">Hanover County Public Schools</option> <option value="Harrisonburg City">Harrisonburg City Public Schools</option> <option value="Henrico County">Henrico County Public Schools</option> <option value="Henry County">Henry County Public Schools</option> <option value="Highland County">Highland County Public Schools</option> <option value="Hopewell City">Hopewell City Public Schools</option> <option value="Isle of Wight County">Isle of Wight County Public Schools</option> <option value="James City">James City County</option> <option value="King George">King George County Public Schools</option> <option value="King William">King William County Public Schools</option> <option value="King and Queen">King and Queen County Public Schools</option> <option value="Lancaster County">Lancaster County Public Schools</option> <option value="Lee County">Lee County Public Schools</option> <option value="Lexington City">Lexington City Public Schools</option> <option value="Loudoun County">Loudoun County Public Schools</option> <option value="Louisa County">Louisa County Public Schools</option> <option value="Lunenburg County">Lunenburg County Public Schools</option> <option value="Lynchburg City">Lynchburg City Public Schools</option> <option value="Madison County">Madison County Public Schools</option> <option value="Manassas City">Manassas City Public Schools</option> <option value="Manassas Park City">Manassas Park City Public Schools</option> <option value="Martinsville City">Martinsville City Public Schools</option> <option value="Mathews County">Mathews County Public Schools</option> <option value="Mecklenburg County">Mecklenburg County Public Schools</option> <option value="Middlesex County">Middlesex County Public Schools</option> <option value="Montgomery County">Montgomery County Public Schools</option> <option value="Nelson County">Nelson County Public Schools</option> <option value="New Kent County">New Kent County Public Schools</option> <option value="Newport News">Newport News City Public Schools</option> <option value="Norfolk City">Norfolk City Public Schools</option> <option value="Northampton County">Northampton County Public Schools</option> <option value="Northumberland County">Northumberland County Public Schools</option> <option value="Norton City">Norton City Public Schools</option> <option value="Nottoway County">Nottoway County Public Schools</option> <option value="Orange County">Orange County Public Schools</option> <option value="Page County">Page County Public Schools</option> <option value="Patrick County">Patrick County Public Schools</option> <option value="Petersburg City">Petersburg City Public Schools</option> <option value="Pittsylvania County">Pittsylvania County Public Schools</option> <option value="Poquoson City">Poquoson City Public Schools</option> <option value="Portsmouth City">Portsmouth City Public Schools</option> <option value="Powhatan County">Powhatan County Public Schools</option> <option value="Prince Edward County">Prince Edward County Public Schools</option> <option value="Prince George County">Prince George County Public Schools</option> <option value="Prince William County">Prince William County Public Schools</option> <option value="Pulaski County">Pulaski County Public Schools</option> <option value="Radford City">Radford City Public Schools</option> <option value="Rappahannock County">Rappahannock County Public Schools</option> <option value="Richmond City">Richmond City Public Schools</option> <option value="Richmond County">Richmond County Public Schools</option> <option value="Roanoke City">Roanoke City Public Schools</option> <option value="Roanoke County">Roanoke County Public Schools</option> <option value="Rockbridge County">Rockbridge County Public Schools</option> <option value="Rockingham County">Rockingham County Public Schools</option> <option value="Russell County">Russell County Public Schools</option> <option value="Salem City">Salem City Public Schools</option> <option value="Scott County">Scott County Public Schools</option> <option value="Shenandoah County">Shenandoah County Public Schools</option> <option value="Smyth County">Smyth County Public Schools</option> <option value="Southampton County">Southampton County Public Schools</option> <option value="Spotsylvania County">Spotsylvania County Public Schools</option> <option value="Stafford County">Stafford County Public Schools</option> <option value="Staunton City">Staunton City Public Schools</option> <option value="Suffolk City">Suffolk City Public Schools</option> <option value="Surry County">Surry County Public Schools</option> <option value="Sussex County">Sussex County Public Schools</option> <option value="Tazewell County">Tazewell County Public Schools</option> <option value="Virginia Beach City">Virginia Beach City Public Schools</option> <option value="Warren County">Warren County Public Schools</option> <option value="Washington County">Washington County Public Schools</option> <option value="Waynesboro City">Waynesboro City Public Schools</option> <option value="West Point">West Point Public Schools</option> <option value="Westmoreland County">Westmoreland County Public Schools</option> <option value="Williamsburg-James City">Williamsburg-James City County Public Schools</option> <option value="Winchester City">Winchester City Public Schools</option> <option value="Wise County">Wise County Public Schools</option> <option value="Wythe County">Wythe County Public Schools</option> <option value="York County">York County Public Schools</option> </select>County </p> <p> <input name="director" size="64" maxlength="64" value="<?php echo $escapedDirector?>"/> Alternative Education Director/Coordinator </p> <p> <textarea name="info" rows="10" cols="60"><?php echo $escapedInfo?></textarea> Additional information about the school or program </p> <?php # Display the captcha if we're using my captcha.php system # and the user is not logged in to an Accountable account if ((!$_SESSION['id']) && (function_exists('captchaImgUrl'))) { ?> <p> <b>Please help us prevent fraud</b> by entering the code displayed in the image in the text field. Alternatively, you may click <b>Listen To This</b> to hear the code spoken aloud. </p> <p> <img style="vertical-align: middle" src="<?php echo captchaImgUrl()?>"/> <input name="captcha" size="8"/> <a href="<?php echo captchaWavUrl()?>">Listen To This</a> </p> <?php } ?> <p> <input type="submit" name="send" value="Submit Regestration"/> <input type="submit" name="cancel" value="Cancel"/> </p> <input type="hidden" name="returnurl" value="<?php echo $escapedReturnUrl?>"/> </form> </body> </html> <?php } function redirect() { global $serverName; $returnUrl = $_POST['returnurl']; # Don't get tricked into redirecting somewhere # unpleasant. You never know. Reject the return URL # unless it points to somewhere on our own site. $prefix = "http://$serverName/"; if (!beginsWith($returnUrl, $prefix)) { $returnUrl = "http://$serverName/"; } header("Location: $returnUrl"); } function beginsWith($s, $prefix) { return (substr($s, 0, strlen($prefix)) === $prefix); } function sendMail() { # Global variables must be specifically imported in PHP functions global $recipient; $messages = array(); $email = $_POST['email']; # Allow only reasonable email addresses. Don't let the # user trick us into backscattering spam to many people. # Make sure the user remembered the @something.com part if (!preg_match("/^[\w\+\-\.\~]+\@[\-\w\.\!]+$/", $email)) { $messages[] = "That is not a valid email address. Perhaps you left out the @something.com part?"; } $realName = $_POST['name']; if (!preg_match("/^[\w\ \+\-\'\"]+$/", $realName)) { $messages[] = "The real name field must contain only alphabetical characters, numbers, spaces, and the + and - signs. We apologize for any inconvenience."; } $subject = "VAEA Conference Registration"; # CAREFUL: don't allow hackers to sneak line breaks and additional # headers into the message and trick us into spamming for them! $subject = preg_replace('/\s+/', ' ', $subject); # Make sure the subject isn't blank (apart from whitespace) if (preg_match('/^\s*$/', $subject)) { $messages[] = "Please specify a subject for your message."; } $body = $_POST['$name has submited their registration for the 2009 VAEA Conference.\n Their information is as follows: Name: $name\n Title: $title\n email: $email\n Address: $address\n Phone: $phone\n School/Program Name: $school\n Grade Level: $grade\n County: $county\n Alternative Education Director/Coordinator: $director\n Additional information about the school or program: $info']; # Make sure the message has a body if (preg_match('/^\s*$/', $body)) { $messages[] = "Your message was blank. Did you mean to say something? Click the Cancel button if you do not wish to send a message."; } # Check the captcha code if the user is NOT logged in to an account if ((!$_SESSION['id']) && function_exists('captchaImgUrl')) { if ($_POST['captcha'] != $_SESSION['captchacode']) { $messages[] = "You did not enter the security code, or what you entered did not match the code. Please try again."; } } if (count($messages)) { # There were errors, so re-display the form with # the error messages and let the user correct # the problem displayForm($messages); return; } # No errors - send the email mail($recipient, $subject, $body, "From: $name <$email>\r\n" . "Reply-To: $name <$email>\r\n"); # Thank the user and invite them to continue, at which point # we direct them to the page they came from. Don't allow # unreasonable characters in the URL $escapedReturnUrl = htmlspecialchars($_POST['returnurl']); ?> <html> <head> <title>Thank You</title> </head> <body> <h1>Thank You</h1> <p> Thank you for submiting your registration! </p> <form method="POST" action="<?php echo $_SERVER['DOCUMENT_URL']?>"> <input type="submit" name="continue" value="Click Here To Continue"/> <input type="hidden" name="returnurl" value="<?php echo $escapedReturnUrl?>"/> </form> </body> </html> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/125946-trying-to-create-a-form-for-registration/ Share on other sites More sharing options...
.josh Posted September 26, 2008 Share Posted September 26, 2008 To put more than one thing in your email body, you use basic string concatenation. I kind of find it hard to believe that you don't know how to do that, when you (claim to have) wrote all that stuff there... Also, please use code tags when posting code, and make an effort to only post the relevant chunks of code. Link to comment https://forums.phpfreaks.com/topic/125946-trying-to-create-a-form-for-registration/#findComment-651327 Share on other sites More sharing options...
Brian W Posted September 26, 2008 Share Posted September 26, 2008 # Don't put anything above the previous line, not even blank space LOL, the guy didn't right it himself... note the notations, they are obviosly written in a "your info here" kind of format. Dude, its cool if you didn't write it yourself. Go to the third party scripts board because it seems to belong there. But, what you need to do is just make all of the data you want in the body one string. Link to comment https://forums.phpfreaks.com/topic/125946-trying-to-create-a-form-for-registration/#findComment-651333 Share on other sites More sharing options...
thesaleboat Posted September 26, 2008 Share Posted September 26, 2008 i dont know why you guys are being asses... its friday be nice guys! who the hell writes all of the code anymore? 0011001101010010100111000 $body = "Position Applied For: \n".$requiredPosition." "; $body .= "\n\n\nFull Name: \n".$FirstName." ".$MiddleInitial." ".$LastName." "; $body .= "\n\n\nTelephone Number: \n".$TelephoneNumber." "; $body .= "\n\n\nEmail Address: \n".$EmailAddress." "; $body .= "\n\n\nHome Address: \n".$HomeAddress." "; $body .= "\n\n\nSecurity Clearance: \n".$SecurityClearance." "; $body .= "\n\n\nEducation: \n".$Education." "; $body .= "\n\n\nProfessional Experience: \n".$ProfessionalExperience." "; $body .= "\n\n\nProfessional Licenses: \n".$ProfessionalLicenses." "; $body .= "\n\n\nComputer Proficiency: \n".$ComputerProficiency." "; $body .= "\n\n\nMiscellaneous: \n".$Miscellaneous." "; Use something like that... just change the variables to match what you need Link to comment https://forums.phpfreaks.com/topic/125946-trying-to-create-a-form-for-registration/#findComment-651395 Share on other sites More sharing options...
thesaleboat Posted September 26, 2008 Share Posted September 26, 2008 # Don't put anything above the previous line, not even blank space LOL, the guy didn't right it himself... note the notations, they are obviosly written in a "your info here" kind of format. Dude, its cool if you didn't write it yourself. Go to the third party scripts board because it seems to belong there. But, what you need to do is just make all of the data you want in the body one string. and by "right" you mean "write"... right? hahah d.a. Link to comment https://forums.phpfreaks.com/topic/125946-trying-to-create-a-form-for-registration/#findComment-651396 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.