Jump to content

dennisb

Members
  • Posts

    6
  • Joined

  • Last visited

dennisb's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks. I made the changes. My submit looks like this now <input type="image" name="Submit1['cd']" src="images/mail-me-a-hard-copy-cd.gif"> and <input type="image" name="Submit1['cd']" src="images/mail-me-a-hard-copy-cd.gif"> Also, I used this code that you gave me below and placed it below the </form> tag echo '<pre>'.print_r($_POST, 1).'</pre>'; And this is the result that I'm getting. Array( [cd_choice] => 5 [Submit1] => Array ( [\'mp3\'] => 19 )) The page is still reloading regardless of choice I'm selecting, so it looks like my choices are still not passing.
  2. Hi Barand! I'm a bit confused on the syntax of where I would place this code and what exactly I need to do. Please let me know if I understood you correctly: In the "Submit" tags, the names need to be changed so that it will be displaying as: <input type="image" name="Submit1['cd']" src="images/mail-me-a-hard-copy-cd.gif" value = "cd"> and <input type="image" name="Submit1['mp3']" src="images/email-me-download-link.gif" value = "mp3"> Then I need to place the following code somewhere. <script> array ( [Submit1] = array ( [mp3] = y ) ) </script> And this will resolve the issue? Please let me know if I understood you correctly. Thank you!
  3. Here's the code that I currently have. I changed everything to lowercase, but it's still not working. For the "Read testimonial" script, I have the code and it's working fine, so I didn't include it here. <?php if (isset($_POST['cd_choice'])) { $cd = $_POST['cd_choice']; switch($_POST['Submit1']) { case "cd": header("location: mailCD.php?cd=$cd"); exit; break; case "mp3": header("location: downloadCD.php?cd=$cd"); exit; break; } } else { echo "<p>Please select a CD</p>"; } ?> <form name ="form1" method ="post" action =""> <p> <img src="1.jpg" align="right" /><input type = 'Radio' Name ='cd_choice' value= '1'><font size="+1"><b>CD 1</b></font> <a href="#" onClick="showStuff('testimonial1'); return false;">Read testimonial</a><br> <span id="testimonial1" style="display: none;"> <br /><br />“Fascinating! Amazing CD!”<br><br> John Doe, Someplace USA </span> </p> <p> </p> <p> <img src="2.jpg" align="right" /><input type = 'Radio' Name ='cd_choice' value= '2'> <font size="+1"><b>CD 2</b></font> <a href="#" onClick="showStuff('testimonial2'); return false;">Read testimonial</a><br> <span id="testimonial2" style="display: none;"> <br /><br />"Highly suggest this. Great cd."<br><br> Jane Doe </span> </p> <p> </p> <p> <img align="right" src="3.jpg" /><input type = 'Radio' Name ='cd_choice' value= '3'> <font size="+1"><b>CD 3</b></font> <a href="#" onClick="showStuff('testimonial4'); return false;">Read testimonial</a><br> <span id="testimonial4" style="display: none;"> <br /><br />“Remarkable compilation”<br><br> Mr. Smith </span> </p> <p> </p> <p> <img align="right" src="4.jpg" /><input type = 'Radio' Name ='cd_choice' value= '4'> <font size="+1"><b>CD 4</b></font> <a href="#" onClick="showStuff('testimonial3'); return false;">Read testimonial</a><br> <span id="testimonial3" style="display: none;"> <br /><br />"Great cd"<br><br> Jack Doe </span> </p> <p> </p> <img align="right" src="5.jpg" /><input type = 'Radio' Name ='cd_choice' value= '5'> <font size="+1"><b>CD 5</b></font></p> <center> <p> </p> <p> </p> <p> </p> <p> <input type="image" name="Submit1" src="images/mail-me-a-hard-copy-cd.gif" value = "cd"> </p> </center> <p><center><input type="image" name="Submit1" src="images/email-me-download-link.gif" value = "mp3"></center></p> <div align="center"><a href="#">No thanks. </a></div> </form>
  4. Thank you so much, Barand! I tried your version of the code. Whenever I click on any of the "Submit" buttons, the page just refreshes. Here's the exact code I'm using. <?php if (isset($_POST['cd_choice'])) { $cd = $_POST['cd_choice']; switch($_POST['Submit1']) { case "cd": header("location: mailCD.php?cd=$cd"); exit; break; case "mp3": header("location: downloadCD.php?cd=$cd"); exit; break; } } else { echo "<p>Please select a CD</p>"; } ?> <FORM NAME ="form1" METHOD ="POST" ACTION =""> <INPUT TYPE = 'Radio' Name ='cd_choice' value= '1'> This is the first CD<br> <INPUT TYPE = 'Radio' Name ='cd_choice' value= '2'> This is the second CD<br> <INPUT TYPE = 'Radio' Name ='cd_choice' value= '3'> This is the third CD<br> <INPUT TYPE = 'Radio' Name ='cd_choice' value= '4'> This is the fourth CD<br> <P> <center><input type="image" name="Submit1" src="images/mail-me-a-hard-copy-cd.gif" VALUE = "cd"></center> <p><center><input type="image" name="Submit1" src="images/email-me-download-link.gif" VALUE = "mp3"></center></p> <div align="center"><a href="#">No thanks. </a></div> </FORM> I'm using a custom image for the submit button, which is why the submit code is different from what it was before. That shouldn't matter. Should it? I placed the PHP code right above the form in the body. Is there anything that I'm missing? Thanks!
  5. Hi David! It doesn't work for me because if, for example, I click on the first radio button "This is the first CD" and then I click on the first submit button "Yes, please mail me a CD", nothing happens. Nothing happens if I click on the second submit button either. I know that I'm missing some logic somewhere; however, I'm unable to connect the dots and figure out exactly what's missing. Here's an example of what I need it to do. When someone clicks on the first radio button "This is the first CD" and then clicks on the first submit button "Yes, please mail me a CD", the user will be taken to a shopping cart link for that specific CD that user has selected. If the user clicks on that same radio button, but then clicks on the second submit button "Send me download link instead", the user will be taken to a download link for that same MP3. This needs to happed for every selection. This is the reason why two submit buttons were created, so that the user has an option of either getting a physical or digital version of the same CD. Please let me know if this makes sense. Thank you!
  6. I'm trying to create a "Thank you" page where a user lands after he/she has opted into one of our forms. On that page there will be an option for the user to choose a free CD as a gift and will only have to pay for shipping. I would like to give the user an option to either choose a physical CD or a digital MP3. The logic here is that first I provide a user with selection of 4 CDs that I connect to each radio button. Then below that there will be the first Submit button that will say something like "Yes, please mail be a CD." Below the first button there will be a second Submit button that will say something like "Send me the download link instead". Thus if the user clicks on any of the radio buttons and then clicks on the first Submit button, they will be taken to the shopping cart for that CD where they will be prompted to pay the shipping charges for the CD. If the user click on that same radio button, but then clicks on the second Submit button, they will be taken to link to download it. The third link below would just take the user past the page if he chooses to opt out of this offer. I can't get the script to work correctly for me. Here is what I have so far: <?PHP $option1 = 'unchecked'; $option2 = 'unchecked'; $option3 = 'unchecked'; $option4 = 'unchecked'; if (isset($_POST['Submit1'])) { $selected_radio = $_POST['cd_choice']; if ($selected_radio == 'option1') { $option1 = 'checked'; ?> <a href="#">Purchase link 1</a> <?php } else if ($selected_radio == 'option2') { $option2 = 'checked'; ?> <a href="#">Purchase link 2</a> <?php } else if ($selected_radio == 'option3') { $option3 = 'checked'; ?> <a href="#">Purchase link 3</a> <?php } else if ($selected_radio == 'option4') { $option4 = 'checked'; ?> <a href="#">Purchase link 4</a> <?php } } else { $selected_radio = $_POST['cd_choice']; if ($selected_radio == 'option1') { $option1 = 'checked'; ?> <a href="#">Download link 1</a> <?php } else if ($selected_radio == 'option2') { $option2 = 'checked'; ?> <a href="#">Download link 2</a> <?php } else if ($selected_radio == 'option3') { $option3 = 'checked'; ?> <a href="#">Download link 3</a> <?php } else if ($selected_radio == 'option4') { $option4 = 'checked'; ?> <a href="#">Download link 4</a> <?php } } ?> Here's what I have for the HTML portion of it: <body> <FORM NAME ="form1" METHOD ="POST" ACTION ="radioButton_test.php"> <INPUT TYPE = 'Radio' Name ='cd_choice' value= 'option1' <?PHP print $option1; ?>> This is the first CD <INPUT TYPE = 'Radio' Name ='cd_choice' value= 'option2' <?PHP print $option2; ?>> This is the second CD <INPUT TYPE = 'Radio' Name ='cd_choice' value= 'option3' <?PHP print $option3; ?>> This is the third CD <INPUT TYPE = 'Radio' Name ='cd_choice' value= 'option4' <?PHP print $option4; ?>> This is the fourth CD <P> <center><INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Yes, please mail me a CD"></center> <p><center><INPUT TYPE = "Submit" Name = "Submit2" VALUE = "Send me download link instead"></center></p> <div align="center"><a href="#">No thanks. </a></div> </FORM> Any help would be greatly appreciated. Thank you!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.