Search the Community
Showing results for tags 'php forms'.
-
please check screen shot.... for error <div> <?php require_once("sendcontact.php"); $obj = new insertcontact(); $result = $obj->recordcontact(); ?> <?echo "<center>".$result."</center><br><br>"; ?> <form action="" method="post"> <table> <th><center> Please fill the form : </center></th> <tr> <td>Name :</td> <td><input type="text" name="fullname" placeholder="Type your full name"></td> </tr> <tr> <td>email :</td> <td><input type="email" name="email" placeholder="ex: username@example.com"></td> </tr> <tr> <td>Type of contact :</td> <td><input type="checkbox" name="checkbox" value="Report" >Report <br> <input type="checkbox" name="checkbox" value="Feedback" >Feedback <br> <input type="checkbox" name="checkbox" value="Suggestions" >Suggestions <br> </td> </tr> <tr> <td>Message:</td> <td><textarea name="message" style="max-width:500px;" cols="60" rows="10" placeholder="Type message here"></textarea></td> </tr> </table> <input type="submit"> </form> </div> contact.php <?php include('dbconnect.php'); class insertcontact{ public function recordcontact(){ // function for inserting videos $Name = $_POST["fullname"]; $email = $_POST["email"]; $message = $_POST["message"]; $type = $_POST["checkbox"]; $date = new DateTime(); $contactdate = $date-> format('Y-m-d H:i:s'); if(empty($Name) || empty($email) || empty($message) || empty($type)){ return $result = "Missing information....!"; }else{ $strSQL = " INSERT INTO Contact (Name, email, message, contact_type, date ) VALUES ('".$Name."','".$email."','".$message."','".$type."','".$contactdate."')" ; try{ mysql_query($strSQL); $message = "Thank you for submitting."; return $message ; clearstatcache(); exit(); } catch(CustomException $e){ throw new Exception( 'Something really gone wrong', 0, $e); exit(); } } } } ?>
-
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!
- 17 replies
-
- php forms
- radio button
-
(and 3 more)
Tagged with: