benchew0904 Posted November 19, 2011 Share Posted November 19, 2011 Hi I need some help. I have a page which will show all the result based on the user sign in. And it will show something like this ID | Event Start Date | Event End Date | Event Details 1 19-11-2011 20-11-2011 View Event Details The view event details is a link so when I click on the link, it will link me to the next page (eventDetails.php?id=1) And at eventDetails.php?id=1 page, it would requires user to input whether they will be attending or not and will they be bringing their friend along then submit the form. When I submit, how do I pass all the data from eventDetails.php?id=1 page to confirmation.php page (after submitting)? You might want to refer to the attached coding. All the 2 php pages are working fine but when submit to confirmation.php page, the data are not post over so I didn't attach the confirmation.php page. Thanks Ben Chew [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/251433-help-with-php-coding/ Share on other sites More sharing options...
Crono Posted November 19, 2011 Share Posted November 19, 2011 Look into sessions. You can store data like this in the $_SESSION superglobal. Quote Link to comment https://forums.phpfreaks.com/topic/251433-help-with-php-coding/#findComment-1289543 Share on other sites More sharing options...
mikesta707 Posted November 19, 2011 Share Posted November 19, 2011 A few problems I notice. One, here <td><input type="radio" name="type" value="Yes" />Yes <input type="radio" name="type" value="No" />No<br/></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td>Any friends tagging along</td> <td><input type="radio" name="type" value="Yes" />Yes <input type="radio" name="type" value="No" />No<br/></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td><input name="submit" value="Submit" type="submit"></td> <td><input name="reset" value="Reset" type="reset"></td> In PHP, when submitting the form, the values from that form are put into $_POST or $_GET super global array depending on your forms method (in your case, its $_POST since you use the post method). The keys in the array are gotten from the name attribute of the individual input tag. Notice that the name of all your radio buttons are type. When you have two radio buttons that are part of a single group (IE the choice of whether or not you are attending) each radio button in that group should have the same name. However, when you have two or more separate groups (Like whether or not you are attending, and whether or not you are bringing a friend) each separate group should have a separate name. Thus, you may want to change your radio buttons to: <!-- Notice the name attributes --> <td><input type="radio" name="attending" value="Yes" />Yes <input type="radio" name="attending" value="No" />No<br/></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td>Any friends tagging along</td> <!-- Notice the name attributes --> <td><input type="radio" name="bringing_friends" value="Yes" />Yes <input type="radio" name="bringing_friends" value="No" />No<br/></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td><input name="submit" value="Submit" type="submit"></td> <td><input name="reset" value="Reset" type="reset"></td> Upon submitting, on the page this form is submit to, you could then access these values by doing $attending = $_POST['attending']; $bringing_friends = $_POST['bringing_friends']; Now, as for the rest of your problem, you should have posted the code. Your post submit not working correctly on the next page could be for a million different reasons, and without seeing the code we can't really tell you which. I'm not sure why you assumed that because the post was not submitting properly, you didn't need to provide the form processing code, but instead the code that is actually working. The problem is probably on that page! Also, in the future, when posting code (especially such a short script(s)) use the forums BBCode code or php tags, instead of attaching a script. Its a lot easier for us to read and help (as many people either don't want to download or can't download stuff) Quote Link to comment https://forums.phpfreaks.com/topic/251433-help-with-php-coding/#findComment-1289546 Share on other sites More sharing options...
benchew0904 Posted November 20, 2011 Author Share Posted November 20, 2011 Sorry, I'm new to this forum. I dont get what you mean by "use the forums BBCode code or php tags". This is my confirmation.php page <?php include 'dbFunctions.php'; ?> <br/><br/> <?php $event_id = $_POST['event_id']; $start_date = $_POST['start_date']; $end_date = $_POST['end_date']; $event_details = $_POST['event_details']; $attending = $_POST['attending']; $bringing_friends = $_POST['bringing_friends']; ?> <table style="width: 600px" > <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td>Event ID</td> <td><?php echo $result[0]['event_id']; ?></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td>Event Start Date</td> <td><?php echo $result[0]['start_date']; ?></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td>Event Start Date</td> <td><?php echo $result[0]['end_date']; ?></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td>Fixing Date</td> <td><?php echo $result[0]['event_details']; ?></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td>Attendance</td> <td><?php echo $attending; ?></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td>Any friends tagging along</td> <td><?php echo $bringing_friends; ?></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td><input name="submit" value="Back to Events" type="submit"></td> </tr> </table> Thanks Ben Chew Quote Link to comment https://forums.phpfreaks.com/topic/251433-help-with-php-coding/#findComment-1289686 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.