muchomacho
Members-
Posts
10 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
muchomacho's Achievements
Newbie (1/5)
0
Reputation
-
Sending to an email address based on menu selection
muchomacho replied to muchomacho's topic in PHP Coding Help
Thanks a million! It worked great. -
Sending to an email address based on menu selection
muchomacho replied to muchomacho's topic in PHP Coding Help
I am very sorry, I've totally misunderstood your last question therefore my last reply was totally wrong. I am not sure if I should store them in the menu or this should be differents variable? This is where I am totally clueless. Maybe you can help. Thanks again. -
Sending to an email address based on menu selection
muchomacho replied to muchomacho's topic in PHP Coding Help
Hi, I am not planning to store any email address. When the user submits the form it'll go to whatever email or company selected. Thanks -
Hello everyone, How can I send form results to an email address based on what the user selects from a menu? Here's the HTML code: [code] <select name="Company" onChange="redirect(this.options.selectedIndex)" size="1" onFocus="this.style.background='#fff';" onBlur="this.style.background='#F8E2C9';" class="text" style="width:170px;" value="0"> <option selected>- Select Company -</option> <option value="a" selected>A</option> <option value="b">B</option> <option value="c">C</option> </select> [/code] Here's PHP code to send email: [code] //Sending Email to form owner $pfw_header = "From: $Email\n" . "Reply-To: $Email\n"; $pfw_subject = "Job Application"; $pfw_email_to = "someone@abc.com"; $pfw_message = "Company: $Company\n\n" . "First Name: $FirstName\n\n" . "Middle Initial: $MiddleInitial\n\n" . "Last Name: $LastName\n\n" . "Address: $StreetName\n\n" . "City: $City\n\n" . "State: $State\n\n" . "Zip Code: $ZipCode\n\n" . "Phone: $Phone\n\n" . "Best Time to Call: $BestTimetoCall\n\n" . "Email: $Email\n\n" . "High School: $HighSchool\n\n" . "College: $College\n\n" . "Resume: $resume_URL\n\n" . "How Did You Find Us: $HowDidYouFindUs\n\n" . "Referral Name: $ReferralName\n\n" . "Race Ethnic Origin: $RaceEthnicOrigin\n\n" . "Vietnam Veteran: $VietnamVeteran\n\n" . "Decline: $Decline\n"; @mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ; [/code] Any help will be appreciated. Thanks
-
MUCHAS, MUCHAS GRACIAS!!!!! :) Have a wonderful weekend.
-
[code] <?php // Receiving variables [foreach ($Positions as $Pos) @$Company = addslashes($_POST['Company']); @$Pos = addslashes($_POST['Pos']); @$FirstName = addslashes($_POST['FirstName']); @$MiddleInitial = addslashes($_POST['MiddleInitial']); @$LastName = addslashes($_POST['LastName']); @$StreetName = addslashes($_POST['StreetName']); @$City = addslashes($_POST['City']); @$State = addslashes($_POST['State']); @$ZipCode = addslashes($_POST['ZipCode']); @$Phone = addslashes($_POST['Phone']); @$BestTimetoCall = addslashes($_POST['BestTimetoCall']); @$Email = addslashes($_POST['Email']); @$HighSchool = addslashes($_POST['HighSchool']); @$College = addslashes($_POST['College']); @$resume_Name = $_FILES['resume']['name']; @$resume_Size = $_FILES['resume']['size']; @$resume_Temp = $_FILES['resume']['tmp_name']; @$resume_Mime_Type = $_FILES['resume']['type']; @$HowDidYouFindUs = addslashes($_POST['HowDidYouFindUs']); @$ReferralName = addslashes($_POST['ReferralName']); @$RaceEthnicOrigin = addslashes($_POST['RaceEthnicOrigin']); @$VietnamVeteran = addslashes($_POST['VietnamVeteran']); @$Decline = addslashes($_POST['Decline']); function RecursiveMkdir($path) { if (!file_exists($path)) { RecursiveMkdir(dirname($path)); mkdir($path, 0777); } } // Validation if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $Email)) { header("Location: error.php"); exit; } if( $resume_Size == 0) { header("Location: error.php"); exit; } if( $resume_Size >2000000) { //delete file unlink($resume_Temp); header("Location: error.php"); exit; } if( $resume_Mime_Type != "application/msword" AND $resume_Mime_Type != "application/pdf" AND $resume_Mime_Type != "application/vnd.ms-excel" ) { unlink($resume_Temp); header("Location: error.php"); exit; } $uploadFile = "resumes/".$resume_Name; if (!is_dir(dirname($uploadFile))) { @RecursiveMkdir(dirname($uploadFile)); } else { @chmod(dirname($uploadFile), 777); } @move_uploaded_file( $resume_Temp , $uploadFile); @chmod($uploadFile, 644); $resume_URL = "; //Sending Email to form owner $pfw_header = "From: $Email\n" . "Reply-To: $Email\n"; $pfw_subject = "Job Application"; $pfw_email_to = "x@x.com"; $pfw_message = "Company: $Company\n\n" ."Positions: " . join(', ', $Positions) . "\n\n" . "First Name: $FirstName\n\n" . "Middle Initial: $MiddleInitial\n\n" . "Last Name: $LastName\n\n" . "Address: $StreetName\n\n" . "City: $City\n\n" . "State: $State\n\n" . "Zip Code: $ZipCode\n\n" . "Phone: $Phone\n\n" . "Best Time to Call: $BestTimetoCall\n\n" . "Email: $Email\n\n" . "High School: $HighSchool\n\n" . "College: $College\n\n" . "Resume: $resume_URL\n\n" . "How Did You Find Us: $HowDidYouFindUs\n\n" . "Referral Name: $ReferralName\n\n" . "Race Ethnic Origin: $RaceEthnicOrigin\n\n" . "Vietnam Veteran: $VietnamVeteran\n\n" . "Decline: $Decline\n"; @mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ; //Sending auto respond Email to visitor $pfw_header = "From: x@x.com" . "Reply-To: x@x.com"; $pfw_subject = "Thanks for submitting your resume"; $pfw_email_to = "$Email"; $pfw_message = "$FirstName $LastName\n" . "\n" . "Thank You! Your application has been received."; @mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ; //saving record to MySQL database @$pfw_strQuery = "INSERT INTO `x`(`Company`,`Positions`,`FirstName`,`MiddleInitial`,`LastName`,`StreetName`,`City`,`State`,`ZipCode`,`Phone`,`BestTimetoCall`,`Email`,`HighSchool`,`College`,`HowDidYouFindUs`,`ReferralName`,`RaceEthnicOrigin`,`VietnamVeteran`,`Decline`)VALUES (\"$Company\",\"$Pos\",\"$FirstName\",\"$MiddleInitial\",\"$LastName\",\"$StreetName\",\"$City\",\"$State\",\"$ZipCode\",\"$Phone\",\"$BestTimetoCall\",\"$Email\",\"$HighSchool\",\"$College\",\"$HowDidYouFindUs\",\"$ReferralName\",\"$RaceEthnicOrigin\",\"$VietnamVeteran\",\"$Decline\")" ; @$pfw_host = "localhost"; @$pfw_user = "x"; @$pfw_pw = "x"; @$pfw_db = "x"; $pfw_link = mysql_connect($pfw_host, $pfw_user, $pfw_pw); if (!$pfw_link) { die('Could not connect: ' . mysql_error()); } $pfw_db_selected = mysql_select_db($pfw_db, $pfw_link); if (!$pfw_db_selected) { die ('Can not use $pfw_db : ' . mysql_error()); } //insert new record $pfw_result = mysql_query($pfw_strQuery); if (!$pfw_result) { die('Invalid query: ' . mysql_error()); } mysql_close($pfw_link); header("Location: success.php"); ?> [/code]
-
I've already tried that and is not working. I hate to be such a pest. Any other ideas?
-
Again! Thank so much. You solved my first problem. I am getting back all selections on an email, however, mySQL is only showing the word "array" for the Positions column. How can I save all selections into that cell? Here's my code to save the record into mySQL: [code]@$pfw_strQuery = "INSERT INTO `X`(`Company`,`Positions`,`FirstName`,`MiddleInitial`,`LastName`,`StreetName`,`City`,`State`,`ZipCode`,`Phone`,`BestTimetoCall`,`Email`,`HighSchool`,`College`,`HowDidYouFindUs`,`ReferralName`,`RaceEthnicOrigin`,`VietnamVeteran`,`Decline`)VALUES (\"$Company\",\"$pos\",\"$FirstName\",\"$MiddleInitial\",\"$LastName\",\"$StreetName\",\"$City\",\"$State\",\"$ZipCode\",\"$Phone\",\"$BestTimetoCall\",\"$Email\",\"$HighSchool\",\"$College\",\"$HowDidYouFindUs\",\"$ReferralName\",\"$RaceEthnicOrigin\",\"$VietnamVeteran\",\"$Decline\")" ;[/code]
-
Thanks so much for the reply! The code is now taking the multiple selections and displaing them nicely on the browser, but what I am looking for is (1) Post the array into mySQL table and (2) sending an email with the information. I think my real problem is not knowing how to incorporate [code]($Positions as $pos)[/code] into my existing code: [code] @$Company = addslashes($_POST['Company']); @$Positions = addslashes($_POST['Positions']); @$FirstName = addslashes($_POST['FirstName']); @$MiddleInitial = addslashes($_POST['MiddleInitial']); [/code] [code] $pfw_header = "From: $Email\n" . "Reply-To: $Email\n"; $pfw_subject = "Job Application"; $pfw_email_to = "email"; $pfw_message = "Company: $Company\n\n" . "Positions: $Positions\n\n" [/code]
-
Hello, Does anyone know how to make a SELECT box accept multiple choices and be able to access those values via php? I have tried using multiple, and indeed it does let a user select more than one value - but only one value is passed to the action script. When the PHP script processes the html form, only the word "Array" is returned when the form is submitted. Here's my HTML code: [color=red]select multiple name="Positions[]"[/color] Here's what I have so far for the receiving variables in my action script: [color=red][font=Verdana]@$Positions = $_POST['Positions']; @$Positions = @implode("," , $Positions); @$Company = addslashes($_POST['Company']); @$Positions = addslashes($_POST['Positions']);[/font] [/color] Any help will be greatly appreciated. Thanks :D