PDA

View Full Version : question about Values submitted from web site form



Lflagg
08-02-2007, 06:15 PM
hello,
i have a quick question. im trying to make a simple form, with names, phones, emails, some check boxes (yes or No), etc. where im getting confused is in the code that i have to insert in my "thank you" page. in this part (in blue): $mailbody = "Values submitted from web site form :\n"; do i have to leave the:\n; ? (it was not highlited in blue in the tutorial).
how do i put the values? divided by commas? between ""? i really dont understand this part. can somoene give me an example so i can use it as a base but use my values?
thanks.

Andy128
08-02-2007, 08:44 PM
Yes- leaave the \n

Only change what is in blue to suit your needs.
For example:
$mailbody ="Input from website form- MySite.com:\n";

Andy

Lflagg
08-02-2007, 09:01 PM
thanks Andy! i figured it out....
another question: i have some checkboxes in the form. but when i receive the email (im doing tests still to myself), the values are empty. it doesnt appear if they were checked or not. how do i do this?
thanks again!

Andy128
08-02-2007, 09:07 PM
Check boxes- if you allow multiple selections, requires a little additional scripting. Could you post the php script that you are currently using and also post the link to the form. I will have a look and see what we can do.

Andy

Lflagg
08-02-2007, 09:12 PM
this si the script:
<?PHP
$mailto = "seniorhelpers******.com";
$email = $HTTP_POST_VARS['email'];
if ($email == "") {
$email = $mailto;
}
$mailsubj = "Caregiver Employment Submission Form";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "first, Last, phone_number, second_number, city, state, zip,how_hear_about_us, years_experience,cna,hha,companion,hours_available ,full_time, part_time,day_shift,Night_shift, weekends,live_in,flexible,have_car,email,drives,co mments:\n";
while (list ($key, $val) = each ($HTTP_POST_VARS))
{
if ($key!="submit")
{
$mailbody .= "$key : $val\n";
}
}
mail($mailto, $mailsubj, $mailbody, $mailhead);
?>

the checkboxes are for these values:
CNA, HHA, Companion, Full time, part time, wekkends, live-in, flexible, Day Shift and night shift.

thanks.

Lflagg
08-02-2007, 09:14 PM
the link to the form:

http://seniorhelpersflorida.com/employment.html

Andy128
08-02-2007, 10:27 PM
The reason that they are not showing up is there is no value assigned to it. So in the value portion of those check boxes in question- simply give it a value of "Yes". That way, if it is checked- you will receive a "Yes".

However. You will receive an e-mail with a bunch of yes's and not know where they are supposed to go with. Give it a try and see how it looks in
your e-mail.

If you would like a nice clean format received in your mail do the following:
1- in your form, make sure that all fields that have two or three parts to their name are joined by an underscore. Example: first_name, last_name were done correctly. Do the same for part_time, full_time, day_shift, night_shift, second_phone_number, Hear_from_us, Years_experience, Live_in etc......

2- You have the comments box named Comments? Remove the ? -So it should be Comments

3- Remove the php code that you are using and replace it with this one below: (**Make a copy first incase you don't like my style)

**Stand BY- still writing code

Andy128
08-02-2007, 10:50 PM
Last part of step 3- **Sorry, had to modify what I had originally posted.

<?PHP
$date = date("l jS F Y, g:i A");
$ip = $_SERVER['REMOTE_ADDR'];
$first_name =$_POST['first_name'];
$last_name =$_POST['last_name'];
$phone_number =$_POST['phone_number'];
$second_phone_number =$_POST['second_phone_number'];
$city =$_POST['city'];
$State =$_POST['State'];
$Hear_from_us =$_POST['Hear_from_us'];
$Years_experience =$_POST['Years_experience'];
$cna =$_POST['cna'];
$hha =$_POST['hha'];
$companion =$_POST['companion'];
$Full_time =$_POST['Full_time'];
$part_time =$_POST['part_time'];
$day_shift =$_POST['day_shift'];
$night_shift =$_POST['night_shift'];
$weekends =$_POST['weekends'];
$flexible =$_POST['flexible'];
$Live_in =$_POST['Live_in'];
$havecar =$_POST['havecar'];
$doyoudrive =$_POST['doyoudrive'];
$Comments =$_POST['Comments'];
//////////////////////////////////////////////////////
$mailto = "seniorhelpers******.com";
$email = $HTTP_POST_VARS['email'];
if ($email == "")
{
$email = $mailto;
}
$mailsubj = "Caregiver Employment Submission Form";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "Form Data from Senior Helpers website:\n"
. "-------------------------------------------------------------\n"
. "Received on : $date\n"
. "IP address : $ip\n"
. "-------------------------------------------------------------\n"
. "First Name: $first_name\n"
. "Last Name : $last_name\n"
. "Phone Number: $phone_number\n"
. "Second Phone: $second_phone_number\n"
. "City: $city\n"
. "State: $State\n"
. "-------------------------------------------------------------\n"
. "Hear about us from: $Hear_from_us\n"
. "-------------------------------------------------------------\n"
. "Years of Experience: $Years_experience\n"
. "-------------------------------------------------------------\n"
. "Type of Care Giver-CNA: $cna\n"
. "Type of Care Giver-HHA: $hha\n"
. "Type of Care Giver-Companion: $companion\n"
. "--------------------------------------------------------------\n"
. "Avaliable to work Full Time: $Full_time\n"
. "Avaliable to work Part Time: $part_time\n"
. "Avaliable to work Day Shift: $day_shift\n"
. "Avaliable to work Night Shift: $night_shift\n"
. "Avaliable to work Weekends: $weekends\n"
. "Avaliable to work Flexible: $flexible\n"
. "Avaliable to work Live In: $Live_in\n"
. "--------------------------------------------------------------\n"
. "Do you have a car: $havecar\n"
. "Do you Drive: $doyoudrive\n"
. "--------------------------------------------------------------\n"
. "Email address: $email\n"
. "--------------------------------------------------------------\n"
. "Comments: $Comments\r\n";
mail($mailto,$mailsubj,$mailbody,$mailhead);
?>

Give this a try and see if you like its output a little better.

Andy

Lflagg
08-03-2007, 01:43 AM
wow. thank you so much!!! i will try this code and i will let u know how it worked!
im curious though.... what will this change do?
thanks.

Andy128
08-03-2007, 03:02 AM
It will simply put it in a more readable and organized output. Like I said- try both- print them out and see which you like better. Remember to copy your first one in note pad just in case mine doesn't work or there are problems.

In any event- if you have problems or questions just post abck.

Andy

Lflagg
08-03-2007, 03:04 PM
hello, i tried it and the email didnt come trhough...so i couldnt really check how it looks....

also, i remember u mentioned about having the option to check several checkboxes, that i need another script? have no idea how to do that.
thanks again!

Watdaflip
08-03-2007, 06:25 PM
Alternatively you can just name all of the check boxes the same and add [] at the end.

For instance set the "name" of each checkbox to "hours_available[]"

And then in the script do something like


<?PHP
$mailto = "seniorhelpers******.com";
$hours_available = $HTTP_POST_VARS['hours_available'];
$email = $HTTP_POST_VARS['email'];
if ($email == "") {
$email = $mailto;
}
$mailsubj = "Caregiver Employment Submission Form";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "first, Last, phone_number, second_number, city, state, zip,how_hear_about_us, years_experience,cna,hha,companion,hours_available ,full_time, part_time,day_shift,Night_shift, weekends,live_in,flexible,have_car,email,drives,co mments:\n";
while (list ($key, $val) = each ($HTTP_POST_VARS))
{
if ($key!="submit")
{
$mailbody .= "$key : $val\n";
}
}

$mailbody .= "Hours Available \n";
for($i=0; $i < count($hours_available); $i++)
{
$mailbody .= $hours_available[$i]."\n";
}
mail($mailto, $mailsubj, $mailbody, $mailhead);
?>
And then just set the values for each checkbox to the label you want to display in the email.. so set the values of each checkbox to "Full Time", "Part Time", "Day Shift", etc.


The only disadvantage to doing it this way is that since the rest of the email is being generated and the format isn't hard coded in, doing is this way all the check boxes have to go before or after the the rest of the email body.

Andy's way hard codes the email message, so its in the same order as the form.

Lflagg
08-03-2007, 07:27 PM
oh... u lost me completely....
i have no idea about php or codes...i tried to read the code and figure what to do, but i couldnt....

may i ask you another question? i need 2 different action pages. i have a form for applicants and one for clients that want more info about our services. the "thank you" (action) page for the applicants was working well until i pasted the code that i was given (i don't receive the email even though the email is right). so i dont knwo what to do there....
and then, when the clients fill up the other form, i need them to end up in another "thank you" action page. should i call it action1.php? how do i do this?
thanks so much!

Watdaflip
08-03-2007, 07:54 PM
Theres any number of ways to do it. You can create multiple action pages (you don't even have to call it "action", you can call it client_contact.php, or what not). You can setup multiple forms that each goes to a different .php file to send the email, or have all the forms go to the same one, and write some code to have the php script distinguish which email to use based on which form submitted it.

Lflagg
08-03-2007, 08:15 PM
oh i see! is not the name but the extension PHP.
gotcha! thanks so much.
now.... regarding the checkboxes... still didnt get that part....

Lflagg
08-03-2007, 08:43 PM
i was thinking... how do i do to create this second "action page" which i called Client_contact.php to be related to the clients form inquiry?
what shoud i do with the sumbit button on that page?

Watdaflip
08-03-2007, 10:42 PM
Basically all you do is make copies of all the pages involved with the form. (Normally just the form and the script to process it, but if you have the line at the bottom header("location: somefile.htm"); (or .php) then you will need to make a copy of somefile.

Rename the copies to something meaningful if you wish, but basically you need to change the "action" of the form. It will still be set to action.php (or whatever you call it), or the original form, you need to name it to the copy of that form you created. And then in the second copy of action.php at the bottom if you have the header(... line then change the file in that to the copy you made of that. And then on that copy make whatever success or thank you message change you want

Lflagg
08-04-2007, 01:47 AM
sorry... didn't get it.... i don't have that amount of knowledge....
can u plz explain it to a beginner?
thanks and sorry for bothering...

Craqer
09-03-2007, 07:49 PM
Had a problem and now i get what was wrong.