The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Mail form problem, Radio button not working
ApoMarn
post Feb 5 2018, 11:20 AM
Post #1





Group: Members
Posts: 6
Joined: 12-January 17
Member No.: 26,262



Can anyone tell me what I'm doing wrong here?

$email_message = .......
$email_message = "Medium: ".$medium."\r\n";
$email_message = .....

<FORM action="inspection_copies.php" method="post">
...
<p><input type="radio" name="medium" value="CD-ROM" checked> CD-ROM
<br><input type="radio" name="medium" value="USB drive"> USB drive
...
</FORM></b>

The rest of the form works perfectly but the radio button line sends only the title (Medium) without any value.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Feb 5 2018, 04:13 PM
Post #2


.
********

Group: WDG Moderators
Posts: 7,916
Joined: 10-August 06
Member No.: 7



The example doesn't show how you create the $medium variable, e.g. by using $_POST['medium'] or similar.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Feb 5 2018, 07:54 PM
Post #3


Programming Fanatic
********

Group: Members
Posts: 1,544
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



In this section, each line over writes the previous value.
QUOTE
$email_message = .......
$email_message = "Medium: ".$medium."\r\n";
$email_message = .....
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
ApoMarn
post Feb 9 2018, 04:38 AM
Post #4





Group: Members
Posts: 6
Joined: 12-January 17
Member No.: 26,262



QUOTE(Christian J @ Feb 5 2018, 09:13 PM) *

The example doesn't show how you create the $medium variable, e.g. by using $_POST['medium'] or similar.


Below is the complete text of the mailform input. I have added the radio buttons to an existing form by following an example from an HTML handbook. According to the handbook this is all that's needed, but it doesn't work.

<FORM action="inspection_copies.php" method="post">
<P>Your name:&nbsp; &nbsp; &nbsp; <INPUT size=40 name="name" value="<?php echo getValue('name'); ?>" />
<P>Name and address of school: <br>
<Textarea name="school" rows=6 cols=47><?php echo getValue('school'); ?></TEXTAREA>
<P>Telephone:&nbsp; &nbsp; &nbsp; &nbsp;<INPUT size=40 name="phone" value="<?php echo getValue('phone'); ?>" />
<P>Your e-mail:&nbsp; &nbsp; &nbsp;<INPUT size=40 name="email" value="<?php echo getValue('email'); ?>" />
<P>Title(s) required: <br>
<textarea name="titles" rows=6 cols=47><?php echo getValue('titles'); ?></TEXTAREA>
<p><input type="radio" name="medium" value="CD-ROM" checked> CD-ROM
<br><input type="radio" name="medium" value="USB drive"> USB drive
<P>Comments (e.g. USB drive):<br>
<Textarea name="comments" rows=3 cols=47><?php echo getValue('comments'); ?></TEXTAREA>
<P><input type="submit" value="Send" name="submit">
</FORM>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Feb 9 2018, 05:04 AM
Post #5


Programming Fanatic
********

Group: Members
Posts: 1,544
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



We need to see the PHP code. How do you assign $medium? As Christian J pointed to you must be using '$medium = $_POST['medium']' or similar somewhere.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
ApoMarn
post Feb 13 2018, 12:17 PM
Post #6





Group: Members
Posts: 6
Joined: 12-January 17
Member No.: 26,262



QUOTE(CharlesEF @ Feb 9 2018, 10:04 AM) *

We need to see the PHP code. How do you assign $medium? As Christian J pointed to you must be using '$medium = $_POST['medium']' or similar somewhere.


if (count($errors) == 0) {
$email_message .= "Name: ".clean_string($full_name)."\r\n";
$email_message .= "School: ".clean_string($school)."\r\n";
$email_message .= "Email: ".clean_string($email_from)."\r\n";
$email_message .= "Telephone: ".clean_string($phone)."\r\n";
$email_message .= "Titles requested: ".clean_string($titles)."\r\n";
$email_message .= "Medium: ".$medium."\r\n";
$email_message .= "Comments: ".clean_string($comments)."\r\n";
$headers = 'From: ' . $email_from . "\r\n".'Reply-To: ' . $email_from."\r\n" . 'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
header("Location: $thankyou_page");

I have also tried:
$email_message .= "Medium: ".clean_string($medium)."\r\n";
Do I still need '$medium = $_POST['medium']'?
If so, where does it go?

This post has been edited by ApoMarn: Feb 13 2018, 12:19 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
ApoMarn
post Feb 13 2018, 12:19 PM
Post #7





Group: Members
Posts: 6
Joined: 12-January 17
Member No.: 26,262



That shouldread:

I have also tried:
$email_message .= "Medium: ".clean_string($medium)."\r\n";
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Feb 13 2018, 03:26 PM
Post #8


Programming Fanatic
********

Group: Members
Posts: 1,544
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



QUOTE(ApoMarn @ Feb 13 2018, 11:17 AM) *

I have also tried:
$email_message .= "Medium: ".clean_string($medium)."\r\n";
Do I still need '$medium = $_POST['medium']'?
If so, where does it go?

Of course you need it. When you submit a form all the field values contained in that form are sent to the server in the $_POST array. To use those values in a PHP script you need to grab the values from the $_POST array. Since your code uses a '$medium' variable then the '$medium' variable MUST be set somewhere in your code (where? before you use the variable), '$medium = ????'. So, if you want the value sent from the form then you MUST have '$medium = $_POST['medium']' somewhere. In fact, every form value you use should have the same type of assignment.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
ApoMarn
post Feb 14 2018, 07:06 AM
Post #9





Group: Members
Posts: 6
Joined: 12-January 17
Member No.: 26,262



Cracked it
Thanks
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 17th October 2018 - 01:11 AM